Repository navigation
Documentation inconsistency with the stable ABI #91271
Description
Activity
thatbirdguythatuknownot commented
on Mar 25, 2022 thatbirdguythatuknownotmannequinMannequinAuthorMore actionsIn https://docs.python.org/3/c-api/typeobj.html#static-types, it says that PyTypeObject isn't part of the stable ABI. Yet, in https://docs.python.org/3/c-api/type.html#c.PyTypeObject, it says that PyTypeObject IS part of the stable ABI. Which is true?
- addeddocsDocumentation in the Doc dirDocumentation in the Doc dir
on Mar 25, 2022 - addeddocsDocumentation in the Doc dirDocumentation in the Doc dir
on Mar 25, 2022 Thanks for the report! You're right that this is misleading. I'll clarify the docs for this and other structs.
- struct PyTypeObject is part if the limited API.
- its fields and size are not part of the API or stable ABI.
So. According to PEP-384 (which added all structs in the stable ABI, except Py_buffer), some structs are opaque and others have a few members exposed:
https://peps.python.org/pep-0384/#structuresI will split the latter into 1) structs that have a few fields exposed mainly for backwards compatibility (which, of course, is very important here). Best practice is to treat them as opaque (use getters/setters):
- PyObject (ob_refcnt, ob_type)
- PyVarObject (ob_base, ob_size)
... and 2) structs for which all fields are part of the ABI (and the struct's size as well: for most of these as users are expected to provide arrays):
- PyMethodDef
- PyMemberDef
- PyGetSetDef
- PyModuleDefBase
- PyModuleDef
- PyStructSequence_Field
- PyStructSequence_Desc
- PyType_Slot
- PyType_Spec
- Py_buffer (new in 3.11)
The opaque structs continue to be:
- PyThreadState
- PyInterpreterState
- PyFrameObject
- symtable
- PyWeakReference
- PyLongObject
- PyTypeObject
- added a commit that references this issue
on Aug 5, 2022 - added a commit that references this issue
on Aug 25, 2022 - added a commit that references this issue
on Aug 25, 2022 - added 3 commits that reference this issue
on Aug 25, 2022
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: