]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-107306: Add a Doc Entry for Py_mod_multiple_interpreters (GH-107403) (gh...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 31 Jul 2023 23:15:13 +0000 (16:15 -0700)
committerGitHub <noreply@github.com>
Mon, 31 Jul 2023 23:15:13 +0000 (23:15 +0000)
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 fb344e99aa0da5bef9318684ade69978585fe060)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
Doc/c-api/init.rst
Doc/c-api/module.rst
Doc/howto/isolating-extensions.rst

index 52824b6d88afdaff4eb5f1091faaa1be95c8926c..8b960b06871b17e92d0fc8a3cf1cec8e3710a57a 100644 (file)
@@ -1555,6 +1555,7 @@ function. You can create and destroy them using the following functions:
       in any thread where the sub-interpreter is currently active.
       Otherwise only multi-phase init extension modules
       (see :pep:`489`) may be imported.
+      (Also see :c:macro:`Py_mod_multiple_interpreters`.)
 
       This must be ``1`` (non-zero) if
       :c:member:`~PyInterpreterConfig.use_main_obmalloc` is ``0``.
index 8ca48c852d4e6ffc48a97a76353de714c81d67e6..2b6875d533c82586d75ea37afdf6462bf7370d41 100644 (file)
@@ -376,6 +376,37 @@ The available slot types are:
    If multiple ``Py_mod_exec`` slots are specified, they are processed in the
    order they appear in the *m_slots* array.
 
+.. c:macro:: Py_mod_multiple_interpreters
+
+   Specifies one of the following values:
+
+   .. c:macro:: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
+
+      The module does not support being imported in subinterpreters.
+
+   .. c:macro:: Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED
+
+      The module supports being imported in subinterpreters,
+      but only when they share the main interpreter's GIL.
+      (See :ref:`isolating-extensions-howto`.)
+
+   .. c:macro:: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
+
+      The module supports being imported in subinterpreters,
+      even when they have their own GIL.
+      (See :ref:`isolating-extensions-howto`.)
+
+   This slot determines whether or not importing this module
+   in a subinterpreter will fail.
+
+   Multiple ``Py_mod_multiple_interpreters`` slots may not be specified
+   in one module definition.
+
+   If ``Py_mod_multiple_interpreters`` is not specified, the import
+   machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``.
+
+   .. versionadded:: 3.12
+
 See :PEP:`489` for more details on multi-phase initialization.
 
 Low-level module creation functions
index 60854c3c034d736a8709fc2b1a0163fe3c0e9314..2551fbe87b5c2a4388b709d5ce6155ce8121f1f6 100644 (file)
@@ -1,5 +1,7 @@
 .. highlight:: c
 
+.. _isolating-extensions-howto:
+
 ***************************
 Isolating Extension Modules
 ***************************