Skip to content

Commit 31cd12a

Browse files
[3.12] gh-99113: Add a What's New Entry for PEP 684 (gh-107520) (gh-107523)
gh-99113: Add a What's New Entry for PEP 684 (gh-107520) (cherry picked from commit 79e479c) Co-authored-by: Eric Snow <[email protected]>
1 parent 3f6afaf commit 31cd12a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Doc/whatsnew/3.12.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ New grammar features:
7070

7171
* :pep:`701`: Syntactic formalization of f-strings
7272

73+
Interpreter improvements:
74+
75+
* :ref:`whatsnew312-pep684`
76+
7377
New typing features:
7478

7579
* :pep:`688`: Making the buffer protocol accessible in Python
@@ -277,6 +281,36 @@ The new :class:`inspect.BufferFlags` enum represents the flags that
277281
can be used to customize buffer creation.
278282
(Contributed by Jelle Zijlstra in :gh:`102500`.)
279283

284+
.. _whatsnew312-pep684:
285+
286+
PEP 684: A Per-Interpreter GIL
287+
------------------------------
288+
289+
Sub-interpreters may now be created with a unique GIL per interpreter.
290+
This allows Python programs to take full advantage of multiple CPU
291+
cores.
292+
293+
Use the new :c:func:`Py_NewInterpreterFromConfig` function to
294+
create an interpreter with its own GIL::
295+
296+
PyInterpreterConfig config = {
297+
.check_multi_interp_extensions = 1,
298+
.gil = PyInterpreterConfig_OWN_GIL,
299+
};
300+
PyThreadState *tstate = NULL;
301+
PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
302+
if (PyStatus_Exception(status)) {
303+
return -1;
304+
}
305+
/* The new interpeter is now active in the current thread. */
306+
307+
For further examples how to use the C-API for sub-interpreters with a
308+
per-interpreter GIL, see :source:`Modules/_xxsubinterpretersmodule.c`.
309+
310+
A Python API is anticipated for 3.13. (See :pep:`554`.)
311+
312+
(Contributed by Eric Snow in :gh:`104210`, etc.)
313+
280314
New Features Related to Type Hints
281315
==================================
282316

@@ -1744,6 +1778,12 @@ New Features
17441778

17451779
(Contributed by Eddie Elizondo in :gh:`84436`.)
17461780

1781+
* :pep:`684`: Added the new :c:func:`Py_NewInterpreterFromConfig`
1782+
function and :c:type:`PyInterpreterConfig`, which may be used
1783+
to create sub-interpreters with their own GILs.
1784+
(See :ref:`whatsnew312-pep684` for more info.)
1785+
(Contributed by Eric Snow in :gh:`104110`.)
1786+
17471787
* In the limited C API version 3.12, :c:func:`Py_INCREF` and
17481788
:c:func:`Py_DECREF` functions are now implemented as opaque function calls to
17491789
hide implementation details.

0 commit comments

Comments
 (0)