@@ -99,6 +99,12 @@ New typing features:
99
99
* :pep: `742 `: :data: `typing.TypeIs ` was added, providing more intuitive
100
100
type narrowing behavior.
101
101
102
+ Free-threading:
103
+
104
+ * :pep: `703 `: CPython 3.13 has experimental support for running with the
105
+ :term: `global interpreter lock ` disabled when built with ``--disable-gil ``.
106
+ See :ref: `Free-threaded CPython <free-threaded-cpython >` for more details.
107
+
102
108
New Features
103
109
============
104
110
@@ -1052,6 +1058,46 @@ See :pep:`744` for more details.
1052
1058
Tier 2 IR by Mark Shannon and Guido van Rossum.
1053
1059
Tier 2 optimizer by Ken Jin.)
1054
1060
1061
+ .. _free-threaded-cpython :
1062
+
1063
+ Free-threaded CPython
1064
+ =====================
1065
+
1066
+ CPython will run with the :term: `global interpreter lock ` (GIL) disabled when
1067
+ configured using the ``--disable-gil `` option at build time. This is an
1068
+ experimental feature and therefore isn't used by default. Users need to
1069
+ either compile their own interpreter, or install one of the experimental
1070
+ builds that are marked as *free-threaded *.
1071
+
1072
+ Free-threaded execution allows for full utilization of the available
1073
+ processing power by running threads in parallel on available CPU cores.
1074
+ While not all software will benefit from this automatically, programs
1075
+ designed with threading in mind will run faster on multicore hardware.
1076
+
1077
+ Work is still ongoing: expect some bugs and a substantial single-threaded
1078
+ performance hit.
1079
+
1080
+ The free-threaded build still supports optionally running with GIL enabled at
1081
+ runtime using the environment variable :envvar: `PYTHON_GIL ` or the command line
1082
+ option :option: `-X gil `.
1083
+
1084
+ * Use :func: `!sys._is_gil_enabled ` to determine if the :term: `GIL ` is enabled.
1085
+
1086
+ * Use ``sysconfig.get_config_var("Py_GIL_DISABLED") `` to identify CPython
1087
+ builds configured with ``--disable-gil ``.
1088
+
1089
+ C-API extensions need to be built specifically for the free-threaded build.
1090
+
1091
+ * Extensions that support running with the :term: `GIL ` disabled should use
1092
+ the :c:data: `Py_mod_gil ` slot. Extensions using single-phase init should use
1093
+ :c:func: `PyUnstable_Module_SetGIL ` to indicate whether they support running
1094
+ with the GIL disabled. Importing C extensions that don't use these mechanisms
1095
+ will cause the GIL to be enabled unless the GIL was explicitly disabled with
1096
+ the :envvar: `PYTHON_GIL ` environment variable or the :option: `-X gil=0 `
1097
+ option.
1098
+
1099
+ * pip 24.1b1 or newer is required to install packages with C extensions in the
1100
+ free-threaded build.
1055
1101
1056
1102
1057
1103
Deprecated
0 commit comments