Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60bd111

Browse filesBrowse files
colesburyambv
andauthored
Docs: add whatsnew for free-threading (#118679)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent e7dafdc commit 60bd111
Copy full SHA for 60bd111

File tree

Expand file treeCollapse file tree

1 file changed

+46
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+46
-0
lines changed

‎Doc/whatsnew/3.13.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.13.rst
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ New typing features:
9999
* :pep:`742`: :data:`typing.TypeIs` was added, providing more intuitive
100100
type narrowing behavior.
101101

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+
102108
New Features
103109
============
104110

@@ -1052,6 +1058,46 @@ See :pep:`744` for more details.
10521058
Tier 2 IR by Mark Shannon and Guido van Rossum.
10531059
Tier 2 optimizer by Ken Jin.)
10541060

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.
10551101

10561102

10571103
Deprecated

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.