@@ -69,6 +69,10 @@ New grammar features:
69
69
70
70
* :pep: `701 `: Syntactic formalization of f-strings
71
71
72
+ Interpreter improvements:
73
+
74
+ * :ref: `whatsnew312-pep684 `
75
+
72
76
New typing features:
73
77
74
78
* :pep: `688 `: Making the buffer protocol accessible in Python
@@ -276,6 +280,36 @@ The new :class:`inspect.BufferFlags` enum represents the flags that
276
280
can be used to customize buffer creation.
277
281
(Contributed by Jelle Zijlstra in :gh: `102500 `.)
278
282
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
+
279
313
New Features Related to Type Hints
280
314
==================================
281
315
@@ -1742,6 +1776,12 @@ New Features
1742
1776
1743
1777
(Contributed by Eddie Elizondo in :gh: `84436 `.)
1744
1778
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
+
1745
1785
* In the limited C API version 3.12, :c:func: `Py_INCREF ` and
1746
1786
:c:func: `Py_DECREF ` functions are now implemented as opaque function calls to
1747
1787
hide implementation details.
0 commit comments