Skip to content

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

Open
@colesbury

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions