Skip to content

Commit 5ca1d39

Browse files
committed
Add note to free-threading howto.
1 parent f79daaa commit 5ca1d39

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Doc/howto/free-threading-python.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,33 @@ to re-enable it in a thread-safe way in the 3.14 release. This overhead is
152152
expected to be reduced in upcoming Python release. We are aiming for an
153153
overhead of 10% or less on the pyperformance suite compared to the default
154154
GIL-enabled build.
155+
156+
157+
Behavioral changes
158+
==================
159+
160+
This section describes CPython behavioural changes with the free-threaded
161+
build.
162+
163+
164+
Context variables
165+
-----------------
166+
167+
In the free-threaded build, the flag :data:`~sys.flags.thread_inherit_context`
168+
is set to true by default. In the default GIL-enabled build, the flag
169+
defaults to false. This will cause threads created with
170+
:class:`threading.Thread` to start with a copy of the
171+
:class:`~contextvars.Context()` of the caller of
172+
:meth:`~threading.Thread.start`. If the flag is false, threads start with an
173+
empty :class:`~contextvars.Context()`.
174+
175+
176+
Warning filters
177+
---------------
178+
179+
In the free-threaded build, the flag :data:`~sys.flags.context_aware_warnings`
180+
is set to true by default. In the default GIL-enabled build, the flag defaults
181+
to false. If the flag is true then the :class:`warnings.catch_warnings`
182+
context manager uses a context variable for warning filters. If the flag is
183+
false then :class:`~warnings.catch_warnings` modifies the global filters list,
184+
which is not thread-safe. See the :mod:`warnings` module for more details.

0 commit comments

Comments
 (0)