Repository navigation
Documentation about PyTypeObject being part of the Stable ABI #95300
Description
Activity
- changed the title
[-]Documentation about PyTypeObject being part of the stable ABI[/-][+]Documentation about PyTypeObject being part of the Stable ABI[/+]on Jul 26, 2022 - addeddocsDocumentation in the Doc dirDocumentation in the Doc dirtriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Jul 26, 2022 The former quote should probably read Limited API, not Stable ABI. cc. @encukou
Technically
PyTypeObjectis part of the stable ABI as an opaque struct (whose fields are part of the ABI) because stable ABI uses Limited C API. Maybe it's better to just document it as "part of Limited C API as an opaque struct".Reacted by Erlend E. Aasland and ov2kThis is fixed in https://docs.python.org/3.11/c-api/type.html#c.PyTypeObject
But it would make sense to backport to earlier docs.Reacted by Erlend E. AaslandPR is at #95711
Reacted by Erlend E. Aasland- linked a pull request that will close this issue[3.10] gh-91271: Document which parts of structs are in limited API/stable ABI (GH-32196) #95711
on Aug 5, 2022 I think https://docs.python.org/3/c-api/typeobj.html#static-types still needs to be fixed. https://docs.python.org/3/c-api/stable.html says:
Extensions that only use the Limited API can be compiled once and work with multiple versions of Python.
It's not that
PyTypeObjectisn't part of the Stable ABI, but that its members aren't part of the Limited API.It's both.
In the limited API/stable ABI,PyTypeObjectis opaque (and has been since the beginning). The ABI for an opaque struct is just a pointer, so there's nothing specific toPyTypeObjectin the Stable ABI.(The first part of
PyTypeObjecthappens to be stable across releases, but that's because it's needed for declarations without designated initializers using the regular C- API.)Reacted by Erlend E. AaslandSuggesting to close this as fixed.
- addedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Aug 8, 2022 @ov2k, please feel free to comment if you disagree, have other suggestions, or if something is unclear.
(Not sure if you have permission to reopen – if you do, that's also an option.)- removedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Aug 8, 2022 That's exactly my point, but perhaps I wasn't being clear enough. https://docs.python.org/3/c-api/typeobj.html#static-types makes no reference to
PyTypeObjectbeing opaque, which is the real reason why extension modules using static types must be compiled for a specific Python minor version. It should say something like:Also, since PyTypeObject is only part of the Limited API as an opaque struct...
It makes sense to me, but I've been thinking about API/ABI way too much :)
Could you send a PR to make this clearer? If not I'll get to it eventually.- added a commit that references this issue
on Aug 25, 2022 - added 3 commits that reference this issue
on Aug 25, 2022 - added a commit that references this issue
on Aug 9, 2026
https://docs.python.org/3/c-api/typeobj.html#static-types says:
https://docs.python.org/3/c-api/type.html#c.PyTypeObject says:
I'm not sure what needs to be fixed, but something does. Can extension modules using the Stable ABI use static types now?