Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,10 @@ 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.

.. versionchanged:: 3.12
Each subinterpreter now :ref:`has its own GIL <per-interpreter-gil>`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that this is still an optional feature. Legacy subinterpreters (Py_NewInterpreter) still share the GIL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Let's specify that it is configurable. Different interpreters can share gil or create one per interpreter.



.. c:type:: PyThreadState
Expand Down Expand Up @@ -1711,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
---------------------

Expand All @@ -1722,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
Expand Down
Loading