Skip to content

Commit fb344e9

Browse files
gh-107306: Add a Doc Entry for Py_mod_multiple_interpreters (#107403)
It was added in 3.12 for PEP 684 (per-interpreter GIL).
1 parent abb71c6 commit fb344e9

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Doc/c-api/init.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ function. You can create and destroy them using the following functions:
12871287
in any thread where the sub-interpreter is currently active.
12881288
Otherwise only multi-phase init extension modules
12891289
(see :pep:`489`) may be imported.
1290+
(Also see :c:macro:`Py_mod_multiple_interpreters`.)
12901291
12911292
This must be ``1`` (non-zero) if
12921293
:c:member:`~PyInterpreterConfig.use_main_obmalloc` is ``0``.

Doc/c-api/module.rst

+31
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,37 @@ The available slot types are:
376376
If multiple ``Py_mod_exec`` slots are specified, they are processed in the
377377
order they appear in the *m_slots* array.
378378
379+
.. c:macro:: Py_mod_multiple_interpreters
380+
381+
Specifies one of the following values:
382+
383+
.. c:macro:: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
384+
385+
The module does not support being imported in subinterpreters.
386+
387+
.. c:macro:: Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED
388+
389+
The module supports being imported in subinterpreters,
390+
but only when they share the main interpreter's GIL.
391+
(See :ref:`isolating-extensions-howto`.)
392+
393+
.. c:macro:: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
394+
395+
The module supports being imported in subinterpreters,
396+
even when they have their own GIL.
397+
(See :ref:`isolating-extensions-howto`.)
398+
399+
This slot determines whether or not importing this module
400+
in a subinterpreter will fail.
401+
402+
Multiple ``Py_mod_multiple_interpreters`` slots may not be specified
403+
in one module definition.
404+
405+
If ``Py_mod_multiple_interpreters`` is not specified, the import
406+
machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``.
407+
408+
.. versionadded:: 3.12
409+
379410
See :PEP:`489` for more details on multi-phase initialization.
380411
381412
Low-level module creation functions

Doc/howto/isolating-extensions.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. highlight:: c
22

3+
.. _isolating-extensions-howto:
4+
35
***************************
46
Isolating Extension Modules
57
***************************

0 commit comments

Comments
 (0)