How Python Free Threading Changes Multicore Performance

How Python Free Threading Changes Multicore Performance EduTechBuddy.com © edutechbuddy.com
How Python Free Threading Changes Multicore Performance © edutechbuddy.com
Python's new free-threaded build removes the Global Interpreter Lock, enabling true parallel execution for CPU intensive code. This article examines real-world benchmarks, practical code examples, and the new challenges developers face when writing multithreaded Python.

Python's Global Interpreter Lock (GIL) has long restricted true parallelism in multithreaded code, forcing threads to take turns running Python bytecode. This setup limited threading's usefulness for CPU bound tasks. With the free-threaded build, officially supported from Python 3.14, developers can now run Python code across multiple cores without the GIL holding things back. The free-threaded mode, introduced in PEP 703, first appeared as an experiment in Python 3.13 and became an officially supported feature in Python 3.14. The standard GIL-enabled build remains the default, but free-threaded Python is now available as an optional mode for multicore workloads (official Python documentation).

What the Free Threaded Build Changes

The free-threaded build, labeled python3.15t (with 't' for 'threaded'), removes the GIL and lets Python code run in parallel across CPU cores. This shift matters most for CPU intensive workloads, where threads previously offered no speedup. Python already releases the GIL during I/O, so code waiting on network or file operations has long benefited from threading. The free-threaded build targets cases where Python code itself is the bottleneck. With this mode, Python threads can run in parallel on available cores, but applications need proper thread-level decomposition and thread-safe dependencies to see gains. This approach tackles the bottleneck of parallel Python-level CPU work, but does not replace multiprocessing or optimized native extensions in every use case.

Benchmarking Multithreaded Performance

To see the impact, a benchmark counted all prime numbers below two million using pure Python. The workload was split into equal chunks, each handled by a separate thread. Both the standard and free-threaded builds of Python 3.15.2 ran on an Apple M4 processor, which mixes performance and efficiency cores. Each setup ran five times, and the median result was used. Both builds found 148,933 primes.

ThreadsWith GILWithout GILSpeedup1 | 4.27 s | 4.46 s | 0.96×
2 | 4.02 s | 2.92 s | 1.4×
4 | 4.12 s | 1.95 s | 2.1×
8 | 4.32 s | 1.45 s | 3.0×

With the GIL, adding threads did not cut execution time for CPU bound code. The free-threaded build, though, delivered a threefold speedup on eight threads. Single-threaded performance dropped by about four percent without the GIL, reflecting the cost of making the interpreter thread-safe. The official Python documentation puts average single-threaded overhead at about 1% on macOS ARM64 and up to 8% on x86-64 Linux. Python 3.14 release notes describe the penalty as roughly 5–10% depending on platform and compiler. Interpreter optimizations in recent versions have trimmed this cost from earlier experimental builds.

When Free Threading Makes No Difference

For code that mostly waits—like sleeping, network requests, or file I/O—Python already releases the GIL. Running eight threads that each sleep for one second finishes in about one second on both builds. This shows that I/O bound programs do not gain from the free-threaded build, since their concurrency is already optimized. Python’s documentation separates free-threaded execution from ordinary I/O concurrency: asynchronous event loops and regular threading already handle many network and file-waiting workloads well. The new mode matters when Python code does heavy per-task computation, since that code can become the bottleneck even with many concurrent I/O operations. In Python 3.14, asyncio gained first-class free-threaded support, letting separate event loops in different threads use multiple CPU cores. This can help educational platforms or digital learning tools that process large volumes of data or requests in parallel.

New Challenges: Race Conditions and Shared State

Without the GIL, concurrency bugs that were hidden before can now appear. For example, incrementing a shared counter from multiple threads using count += 1 is not atomic. In the free-threaded build, this can cause lost updates and wrong totals, as threads overwrite each other's changes. Even with the GIL, this operation was not always safe, but the issue rarely surfaced. The right approach is to use a lock to protect shared data or avoid shared mutable state by having each thread return its own result and combining them at the end. This is especially relevant for educators and students learning parallel programming, since explicit synchronization is now needed to avoid race conditions in multithreaded Python code.

How to Try the Free Threaded Build

To try the free-threaded build, install it using uv or select the free-threaded option in the official Python installer. After installing, check that the GIL is disabled by running sys._is_gil_enabled() in the Python interpreter. Free-threaded CPython builds use a t suffix in runtime and ABI identifiers, such as python3.15t and cpython-315t, to set them apart from standard builds. Importing a C extension without free-threading support will cause Python to re-enable the GIL and issue a warning. The official documentation points out that third-party packages, especially those with C or Cython extension modules, may not yet support the build and can trigger the GIL, reducing or removing the expected parallelism. Python 3.15 adds a stable-ABI variant called abi3t, made for extensions compatible with free-threaded builds, and the compatibility matrix distinguishes ordinary tags like cpython-315 from free-threaded tags like cpython-315t. Developers and educators should check that their dependencies provide compatible wheels, or the expected speedup may not happen (Python on macOS documentation).

Practical Considerations for Developers

Developers working with CPU heavy pure Python code that can be parallelized across threads will see real performance gains from the free-threaded build. For I/O bound workloads, nothing changes. Single-threaded programs may run a bit slower due to the extra overhead, with the penalty ranging from about 1% to 10% depending on hardware and platform. Code that shares mutable data between threads now needs explicit synchronization, such as locks, to avoid race conditions. C extensions that have not declared free-threading support will trigger the GIL, limiting the benefits. By Python 3.14, the implementation had moved past its experimental 3.13 phase and gained more performance work, including activation of the specializing adaptive interpreter in free-threaded mode. The 3.14 release notes report that standard benchmark results improved by 10–20% after a new per-thread doubly linked list for native tasks was introduced, along with reduced memory usage. Python 3.15 continues the transition by adding PEP 803, which provides a stable ABI for free-threaded builds, and by expanding optimization support.

For a broader look at how Python's threading model compares to other languages in multicore computation, see this earlier breakdown. For more technical details and up-to-date compatibility information, check the official Python support for free threading.

Camila Ferreira Editor EduTechBuddy.com
Co-Founder

Camila Ferreira

Camila Ferreira is the Co-Founder of EduTechBuddy, where her editorial focus is programming education and practical software development skills. Her primary subjects include Python programming, Git version control, and the fundamental concepts beginners need to understand when working with code.