Skip to content

Commit 3f6afaf

Browse files
[3.12] gh-107306: Add a Doc Entry for Py_mod_multiple_interpreters (GH-107403) (gh-107521)
gh-107306: Add a Doc Entry for Py_mod_multiple_interpreters (GH-107403) It was added in 3.12 for PEP 684 (per-interpreter GIL). (cherry picked from commit fb344e9) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
1 parent fd60855 commit 3f6afaf

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
@@ -1555,6 +1555,7 @@ function. You can create and destroy them using the following functions:
15551555
in any thread where the sub-interpreter is currently active.
15561556
Otherwise only multi-phase init extension modules
15571557
(see :pep:`489`) may be imported.
1558+
(Also see :c:macro:`Py_mod_multiple_interpreters`.)
15581559
15591560
This must be ``1`` (non-zero) if
15601561
: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)