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 of Py_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