Skip to content

Documentation about PyTypeObject being part of the Stable ABI #95300

Description

@ov2k

https://docs.python.org/3/c-api/typeobj.html#static-types says:

Also, since PyTypeObject is not part of the stable ABI, any extension modules using static types must be compiled for a specific Python minor version.

https://docs.python.org/3/c-api/type.html#c.PyTypeObject says:

Part of the Stable ABI.

I'm not sure what needs to be fixed, but something does. Can extension modules using the Stable ABI use static types now?

Activity

  1. 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
  2. added
    docsDocumentation in the Doc dir
    triagedThe issue has been accepted as valid by a triager.
    type-bugAn unexpected behavior, bug, or error
    on Jul 26, 2022
  3. erlend-aasland commented on Jul 26, 2022

    @erlend-aasland
    Contributor

    The former quote should probably read Limited API, not Stable ABI. cc. @encukou

  4. kumaraditya303 commented on Jul 27, 2022

    @kumaraditya303
    Contributor

    Technically PyTypeObject is 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".

  5. encukou commented on Jul 27, 2022

    @encukou
    Member

    This 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.

  6. encukou commented on Aug 5, 2022

    @encukou
    Member

    PR is at #95711

  7. ov2k commented on Aug 5, 2022

    @ov2k
    ContributorAuthor

    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 PyTypeObject isn't part of the Stable ABI, but that its members aren't part of the Limited API.

  8. encukou commented on Aug 8, 2022

    @encukou
    Member

    It's both.
    In the limited API/stable ABI, PyTypeObject is opaque (and has been since the beginning). The ABI for an opaque struct is just a pointer, so there's nothing specific to PyTypeObject in the Stable ABI.

    (The first part of PyTypeObject happens to be stable across releases, but that's because it's needed for declarations without designated initializers using the regular C- API.)

  9. erlend-aasland commented on Aug 8, 2022

    @erlend-aasland
    Contributor

    Suggesting to close this as fixed.

  10. added
    pendingThe issue will be closed if no feedback is provided
    on Aug 8, 2022
  11. encukou commented on Aug 8, 2022

    @encukou
    Member

    @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.)

  12. removed
    pendingThe issue will be closed if no feedback is provided
    on Aug 8, 2022
  13. ov2k commented on Aug 11, 2022

    @ov2k
    ContributorAuthor

    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 PyTypeObject being 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...

  14. encukou commented on Aug 17, 2022

    @encukou
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtopic-C-APItriagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions