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