From 859897db6d3e3f11fb12c158976c2d4545aa6207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Mon, 8 Sep 2025 12:58:20 +0200 Subject: [PATCH 1/2] Doc/c-api: GIL is no longer shared between subinterpreters It seems the C API documentation still specified the state before https://peps.python.org/pep-0684/. Remove the obsolete note. --- Doc/c-api/init.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index b99988f743dcf2..8980706f2723d4 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1016,9 +1016,7 @@ code, or when embedding the Python interpreter: this structure. Threads belonging to different interpreters initially share nothing, except - process state like available memory, open file descriptors and such. The global - interpreter lock is also shared by all threads, regardless of to which - interpreter they belong. + process state like available memory, open file descriptors and such. .. c:type:: PyThreadState From 83ad9269307f7597bc56457382f7ce79e4de637f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neum=C3=BCller?= Date: Mon, 8 Sep 2025 13:26:47 +0200 Subject: [PATCH 2/2] Add versionchanged --- Doc/c-api/init.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 8980706f2723d4..b6dda837f739c0 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1018,6 +1018,9 @@ code, or when embedding the Python interpreter: Threads belonging to different interpreters initially share nothing, except process state like available memory, open file descriptors and such. + .. versionchanged:: 3.12 + Each subinterpreter now :ref:`has its own GIL `. + .. c:type:: PyThreadState @@ -1709,6 +1712,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 --------------------- @@ -1720,7 +1725,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