From f0445a288305e1c327b2415985ab4352c94ec6a1 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 8 Sep 2025 14:40:53 +0300 Subject: [PATCH 1/4] gh-138644: Update c-api docs of `PyInterpreterState` about PEP-684 --- Doc/c-api/init.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index b99988f743dcf2..0b17ca99397433 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1020,6 +1020,11 @@ code, or when embedding the Python interpreter: interpreter lock is also shared by all threads, regardless of to which interpreter they belong. + .. versionchanged:: 3.12 + + :pep:`684` introduced a possibility of :ref:`per-interpreter` GIL. + See :c:func:`Py_NewInterpreterFromConfig`. + .. c:type:: PyThreadState @@ -1711,6 +1716,8 @@ function. You can create and destroy them using the following functions: haven't been explicitly destroyed at that point. +.. _per-interpreter-gil: + A Per-Interpreter GIL --------------------- @@ -1722,7 +1729,7 @@ being blocked by other interpreters or blocking any others. Thus a single Python process can truly take advantage of multiple CPU cores when running Python code. The isolation also encourages a different approach to concurrency than that of just using threads. -(See :pep:`554`.) +(See :pep:`554` and :pep:`684`.) Using an isolated interpreter requires vigilance in preserving that isolation. That especially means not sharing any objects or mutable From d81f8684821ef2e2105aa367bf990f2ee1899cd0 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 8 Sep 2025 15:08:40 +0300 Subject: [PATCH 2/4] Address review --- Doc/c-api/init.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 0b17ca99397433..fb99068956aaf8 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1022,7 +1022,7 @@ code, or when embedding the Python interpreter: .. versionchanged:: 3.12 - :pep:`684` introduced a possibility of :ref:`per-interpreter` GIL. + :pep:`684` introduced the possibility of a :ref:` Date: Mon, 8 Sep 2025 15:14:03 +0300 Subject: [PATCH 3/4] Fix CI --- Doc/c-api/init.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index fb99068956aaf8..9d77708c6dbef6 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1022,7 +1022,8 @@ code, or when embedding the Python interpreter: .. versionchanged:: 3.12 - :pep:`684` introduced the possibility of a :ref:`` GIL. See :c:func:`Py_NewInterpreterFromConfig`. From ec71d509d446da304397a36237161b68ec8cbbb0 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 8 Sep 2025 15:32:06 +0300 Subject: [PATCH 4/4] Update Doc/c-api/init.rst Co-authored-by: Peter Bierma --- Doc/c-api/init.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 9d77708c6dbef6..bb9e08acee14c2 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1023,7 +1023,7 @@ code, or when embedding the Python interpreter: .. versionchanged:: 3.12 :pep:`684` introduced the possibility - of a :ref:`per-interpreter ` GIL. + of a :ref:`per-interpreter GIL `. See :c:func:`Py_NewInterpreterFromConfig`.