Skip to content

Commit 79e479c

Browse files
gh-99113: Add a What's New Entry for PEP 684 (gh-107520)
1 parent db361a3 commit 79e479c

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
@@ -69,6 +69,10 @@ New grammar features:
6969

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

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

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

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

@@ -1742,6 +1776,12 @@ New Features
17421776

17431777
(Contributed by Eddie Elizondo in :gh:`84436`.)
17441778

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy