Skip to content

Allow C extensions to declare compatibility with free-threading #116322

Closed
@swtaarrs

Description

@swtaarrs

Feature or enhancement

There are a few pieces to this:

  1. 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.
  2. Add a PyModule_ExperimentalSetGIL() function (discussed here) that single-phase init modules can use in place of Py_mod_gil.
  3. Mark all built-in modules as free-threading compatible with one of the above mechanisms.
  4. 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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions