Python-SIP/sip

Add support for Python builds with the GIL disabled

Opened this issue · 0 comments

Support for Python builds with the GIL disabled will be implemented in a later version of ABI v14. This support is highly dependent on API calls implemented in Python v3.13. In addition extension modules built for Python with the GIL disabled are not binary compatible with conventional Python. (Note that the Python ABI tag has been extended to indicated whether or not the GIL is used.)

In more detail:

  • The sip module implementation and SIP generated code will test a build-time macro to determine if it should support a disabled GIL.
  • The SIP build tools will have an option to build a version with the GIL disabled. sip-wheel will use a tag that targets the correct limited API version and ABI tag.
  • The sip module (for Python v3.13 and later) would remove all uses of the GIL and use multiple PyMutex objects as required (most obviously for controlling access to the object map). The value of the Py_mod_gil slot would be Py_MOD_GIL_NOT_USED.
  • The %Module directive will be extended with a gil attribute with used and unused as possible values (defaulting to the former).
  • Any SIP generated calls to the Python API that return borrowed references (eg. PyList_GetItem()) should call the equivalent that returns a new reference (ie. PyList_GetItemRef()). This should be dependent on build-time checks of the Python version. A project's handwritten code must implement similar changes.

The topic needs further investigation.