Skip to content

--disable-gil builds are not compatible with the limited API #111506

Description

@colesbury

Bug report

After #110764, --disable-gil builds of CPython 3.13 are (temporarily) not be compatible with the limited API or the stable ABI due to modifications to the PyObject header. For context, this was noted in the "Backwards Compatibility" section of PEP 703.

Based on feedback on the related discuss post and discussions with Gregory Smith, Guido, Petr, and Victor at the core dev sprint, I believe we can make changes to the stable ABI so that extension author can target a single stable ABI that supports CPython 3.7+ and both the default build and the --disable-gil builds of CPython 3.13+.

These changes will require a PEP. This issue is intended just to keep track of the known problem.

The rough idea is:

  1. make a number of macro/inline functions (e.g., Py_SIZE, Py_TYPE, Py_SET_REFCNT, Py_REFCNT) "real" function calls in the stable ABI for CPython 3.13+
  2. When targeting CPython <= 3.12, use dynamic symbol lookup (GetProcAddress on Windows) or weak symbols (on Linux/macOS) to determine at runtime if the active CPython version provides the desired functions. Otherwise, fall back to old definitions of the above functions for CPython <= 3.12.

Linked PRs

Activity

  1. corona10 commented on Oct 30, 2023

    @corona10
    Member
  2. added 2 commits that reference this issue on Oct 30, 2023
  3. vstinner commented on Oct 30, 2023

    @vstinner
    Member

    Before creating a whole new ABI, I would like first to avoid __asm__(...); in Include/*.h, in the limited C API. Assembly code is not portable and can cause compilation issues.

    A first step for that is to implement Py_SET_REFCNT() as a function call: PR #111508.

  4. added a commit that references this issue on Oct 30, 2023
  5. encukou commented on Oct 31, 2023

    @encukou
    Member

    These changes will require a PEP.

    Please, could we have the PEP first, then do the changes?

  6. added a commit that references this issue on Nov 3, 2023
  7. added 2 commits that reference this issue on Dec 5, 2023
  8. encukou commented on Dec 5, 2023

    @encukou
    Member

    Please, could we have the PEP first, then do the changes?

    @colesbury, do you still plan to write the PEP? Do you need any help?

  9. colesbury commented on Dec 5, 2023

    @colesbury
    ContributorAuthor

    @encukou, yes I still intend to write the PEP. It just hasn't been as a high a priority as integrating the pieces of PEP 703.

  10. 34 remaining items

  11. added a commit that references this issue on Nov 19, 2025
  12. added a commit that references this issue on Dec 4, 2025
  13. kumaraditya303 commented on Apr 5, 2026

    @kumaraditya303
    Contributor

    Closing this in favor of #146636 which implements abi3t

  14. added a commit that references this issue on May 11, 2026
  15. added a commit that references this issue on May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions