Closed
Description
Feature or enhancement
There are a few pieces to this:
- Add a
Py_mod_gil
slot, as described in PEP 703, that multi-phase init modules can use to indicate that they support free-threading. - Add a
PyModule_ExperimentalSetGIL()
function (discussed here) that single-phase init modules can use in place ofPy_mod_gil
. - Mark all built-in modules as free-threading compatible with one of the above mechanisms.
- Enable the GIL while loading a C module and leave it permanently enabled if the module does not declare free-threading compatibility.
1-3 are addressed in gh-116882; 4 will be addressed in a separate PR.
Linked PRs
- gh-116322: Add Py_mod_gil module slot #116882
- gh-116322: Enable the GIL while loading C extension modules #118560
- gh-116322: Rename PyModule_ExperimentalSetGIL to PyUnstable_Module_SetGIL #118645
- gh-116322: Fix typo in the #ifdef check #122268
- gh-116322: Fix typo in moduleobject.c #122282
- [3.13] gh-116322: Fix typo in the GH-ifdef check (GH-122268) #122284