-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-124370: Add "howto" for free-threaded Python #124371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5b4a8aa
0252cf5
df1489e
5658fa8
ae0f637
1554fb9
3b173e0
91ec1ca
6078cfd
e02ed00
526737e
f24bdb7
a3ad6b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,8 @@ | |
Python experimental support for free threading | ||
********************************************** | ||
|
||
Starting with the 3.13 release, CPython has experimental support for running | ||
with the :term:`global interpreter lock` (GIL) disabled in a build of Python | ||
called :term:`free threading`. This document describes the implications of | ||
Starting with the 3.13 release, CPython has experimental support for a build of Python | ||
called :term:`free threading` where the :term:`global interpreter lock` (GIL) is disabled. This document describes the implications of | ||
free threading for Python code. See :ref:`freethreading-extensions-howto` for | ||
information on how to write C extensions that support the free-threaded build. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we could add a quick snapshot of the overall plan: if everything works out, eventually free threading will be the only build, etc. Also, maybe a statement about how most programmer won't need to be concerned with this, we're doing a lot to keep everyday Python programs behaving the same, etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would perhaps add a note in the seealso block that refers to the PEP and adds 1 or 2 highlights:
|
||
|
@@ -52,12 +51,12 @@ Thread safety | |
============= | ||
|
||
The free-threaded build of CPython aims to provide similar thread-safety | ||
behavior at the Python level to the GIL-enabled build. Built-in | ||
behavior at the Python level to the default GIL-enabled build. Built-in | ||
types like :class:`dict`, :class:`list`, and :class:`set` use internal locks | ||
to protect against concurrent modifications in ways that behave similarly to | ||
the GIL. However, Python has not historically guaranteed specific behavior for | ||
concurrent modifications to these built-in types, so this should be treated | ||
as a description of the current implementation, not a guarantee of future | ||
as a description of the current implementation, not a guarantee of current or future | ||
behavior. | ||
|
||
.. note:: | ||
|
@@ -82,7 +81,8 @@ multi-threaded scaling. This means that these objects are never deallocated. | |
This is expected to be addressed in Python 3.14 with | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "addressed" how? That makes it sound like immortal objects are a problem. Are they? |
||
`deferred reference counting <https://peps.python.org/pep-0703/#deferred-reference-counting>`_. | ||
ZeroIntensity marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The objects that are immortalized are: | ||
An object will be made immortal when a new thread is started for the first time after the main thread is running. | ||
The following objects are immortalized: | ||
|
||
* :ref:`function <user-defined-funcs>` objects declared at the module level | ||
* :ref:`method <instance-methods>` descriptors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We seem to switch between "free threading" and "free-threaded" kind of randomly. I can't decide if this is OK or if we should choose one and stick with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine. We also say both "multithreaded" and "multithreading" depending on the context.