Free-Threaded Python, Measured: Threads Finally Scale, and Your Unlocked Counter Finally Breaks
Python 3.14 made the no-GIL build officially supported, and 3.15 kept going. I ran the same CPU-bound job on standard and free-threaded builds of both: threads went from slower-than-serial to 1.9x faster, and a counter that never lost an update under the GIL lost 70% of them without it.
For thirty years the answer to "why won't my Python threads use more than one core" has been the same four letters. The Global Interpreter Lock lets exactly one thread run Python bytecode at a time. Threads were for waiting on sockets. If you wanted parallel CPU work, you forked processes, paid for the pickling, and moved on with your life.
That answer is now optional. Python 3.14 moved the free-threaded build from experimental to officially supported, and 3.15 added a stable ABI for it. The "What's New in Python 3.14" page puts it plainly: "The free-threaded build of Python is now supported and no longer experimental." So I installed standard and free-threaded builds of both 3.14.10 and 3.15.2 and ran the same work through each one to see what you actually get, what it costs, and what it breaks.
Free-Threaded Python: What Changes When the GIL Is Gone
The free-threaded build is a separate interpreter. You don't flip a flag in your normal python3; you install a different binary, usually named python3.14t or python3.15t. python -VV says "free-threading build," and the docs recommend checking sysconfig.get_config_var("Py_GIL_DISABLED") for the build and sys._is_gil_enabled() for what is actually happening at runtime. Those two can disagree, and that gap is where half the surprises in this article live.
Where it stands, from the primary sources:
| Status | Source | |
|---|---|---|
| 3.13 | Experimental, opt-in build | PEP 703 |
| 3.14 | Phase II: "officially supported but still optional" | What's New in 3.14, PEP 779 |
| 3.15 | Stable ABI for free-threaded builds (abi3t, PEP 803); macOS installer includes it by default |
What's New in 3.15 |
| Phase III (free-threading as default) | "still undecided" | What's New in 3.14 |
PEP 779 set the bar for phase II at a 15% single-thread slowdown and 20% extra memory, both as geometric means on pyperformance. The 3.14 release notes claim the single-thread penalty is "now roughly 5-10%, depending on the platform and C compiler used," and the free-threading HOWTO gives a range of "about 1% on macOS aarch64 to 8% on x86-64 Linux systems."
Those are project-reported numbers on the project's own suite. Here is what I got.
The Test Rig
One honest disclosure first: this is a 2-vCPU Xeon VM at 2.1 GHz. The ceiling for any parallel speedup here is 2x. A 16-core box would show bigger multiples, but the shape of the results is what matters, and the shape doesn't change with core count.
Builds were the python-build-standalone binaries that uv python install pulls: 3.14.10 and 3.15.2, each in standard and +freethreaded flavors, all compiled with Clang 23.1.3 on November 11.
The workload is pure-Python trial-division prime counting. It's deliberately dumb CPU work: no I/O, no C extensions, nothing for the GIL to release around. Four jobs, run serially, then on a thread pool, then on a process pool.
import os, sys, sysconfig, time
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
def work(n):
# pure-Python CPU work: count primes below n by trial division
count = 0
for i in range(2, n):
is_prime = True
j = 2
while j * j <= i:
if i % j == 0:
is_prime = False
break
j += 1
if is_prime:
count += 1
return count
def timed(label, fn):
t = time.perf_counter(); fn(); dt = time.perf_counter() - t
print(f"{label:<26}{dt:7.2f} s")
return dt
if __name__ == "__main__":
ft = sysconfig.get_config_var("Py_GIL_DISABLED")
gil = sys._is_gil_enabled()
print(f"{sys.version.split()[0]} free-threaded build={bool(ft)} GIL enabled={gil} cores={os.cpu_count()}")
N, JOBS = 400_000, 4
timed("serial, 4 jobs", lambda: [work(N) for _ in range(JOBS)])
for w in (2, 4):
with ThreadPoolExecutor(w) as ex:
timed(f"threads x{w}", lambda: list(ex.map(work, [N] * JOBS)))
with ProcessPoolExecutor(2) as ex:
timed("processes x2", lambda: list(ex.map(work, [N] * JOBS)))
Threads vs Processes vs Serial, Four Builds
Median of three runs each, in seconds. Lower is better.
| Build | Serial | Threads x2 | Threads x4 | Processes x2 |
|---|---|---|---|---|
| 3.14.10 (GIL) | 2.59 | 3.10 | 3.14 | 1.49 |
| 3.14.10t (free-threaded) | 3.04 | 1.61 | 1.57 | 1.69 |
| 3.15.2 (GIL) | 2.63 | 2.85 | 2.95 | 1.54 |
| 3.15.2t (free-threaded) | 2.82 | 1.62 | 1.56 | 1.63 |
Read the GIL rows first, because they're the part people forget. On the standard builds, a thread pool is slower than doing the work in a plain loop: 3.10 seconds against 2.59 on 3.14. That's not the threads doing nothing. It's the threads fighting over the lock, with each handoff costing more than the work it's protecting. Two threads made CPU-bound Python about 20% slower. This has been true forever and it's still true on the default build.
On the free-threaded builds the same thread pool finishes in about 1.6 seconds, a 1.9x speedup over the free-threaded serial run on a box that can't do better than 2x. Going from two threads to four does nothing useful because there are only two cores, which is exactly what should happen.
Processes still work fine on both builds, and on this tiny job they're within noise of free-threaded threads. That's the comparison you should actually be making. Free threading doesn't beat multiprocessing on raw speed. It beats it on everything around the speed: no pickling of arguments and results, no duplicated memory per worker, shared objects without multiprocessing.shared_memory gymnastics, and no spawn cost. When your work items are big shared data structures, that's the whole game.
We recommend reading Python 3.15: Lazy Imports, Frozendict, and a Faster JIT to continue reading our selection of content. The other half of what 3.15 changed, from lazy imports to the JIT numbers, is there.
Python 3.15: Lazy Imports, Frozendict, and a Faster JIT Python 3.15 release candidate: explicit lazy imports, the new frozendict and sentinel types, the Tachyon profiler, and real JIT benchmark numbers. SudoSecurity · Roel
What You Pay When You're Only Using One Thread
The serial column above already hints at it: 3.04 vs 2.59 seconds on 3.14, 2.82 vs 2.63 on 3.15. That's 17% and 7%. To get a wider view I wrote five small single-threaded workloads and ran each one 15 times per build, interleaving builds so a noisy neighbor on the VM couldn't tilt one build's numbers. The table is the best of the 15.
| Workload (best of 15, ms) | 3.14.10 | 3.14.10t | Cost | 3.15.2 | 3.15.2t | Cost |
|---|---|---|---|---|---|---|
| Prime loop (integer math) | 126.5 | 181.3 | +43% | 132.7 | 181.5 | +37% |
| JSON dump/load round trip | 233.6 | 326.7 | +40% | 283.2 | 327.0 | +15% |
| Object create + method call | 220.6 | 222.4 | +1% | 274.4 | 257.6 | −6% |
| f-string building + join | 74.2 | 94.4 | +27% | 80.4 | 74.4 | −7% |
| dict get/set | 70.9 | 79.8 | +13% | 59.5 | 79.0 | +33% |
That's a mess, and I'm leaving it as a mess because that's what it is. A shared VM is a terrible place to measure a 5% effect. Two things hold up anyway. First, tight integer loops paid the most on both versions, around 40%. Second, nothing got faster in a way that would survive a rerun. If your hot path is a single-threaded loop crunching numbers in pure Python, the free-threaded build costs you real time, and the project's own 5–10% average doesn't describe your workload.
The memory side was tidier. The same script holding 500,000 small dicts and a million bare object() instances:
| Peak RSS | sys.getsizeof(None) |
|
|---|---|---|
| 3.14.10 | 176.2 MB | 16 |
| 3.14.10t | 219.4 MB | 32 |
| 3.15.2 | 180.4 MB | 16 |
| 3.15.2t | 223.3 MB | 32 |
That's about 24% more. The HOWTO explains why: non-GC objects carry a bigger header ("None uses 32 bytes on the free-threaded build vs 16 bytes for the default build"), the build uses mimalloc instead of pymalloc, and some frees are deferred through a scheme called QSBR so another thread can't be reading memory as it disappears. It also warns that every interned string becomes immortal for the life of the process. If you run thirty worker processes and plan to replace them with one process full of threads, you'll come out far ahead on memory anyway. If you're just swapping interpreters under an existing multiprocess app, you're paying about a quarter more RAM for nothing.
The Bug the GIL Was Hiding
This is the part that should worry you more than any benchmark. Here's code I'd bet exists in a lot of production Python:
import sys, threading
counter = 0
def bump(n):
global counter
for _ in range(n):
counter += 1 # read, add, write: not atomic
N, T = 1_000_000, 4
threads = [threading.Thread(target=bump, args=(N,)) for _ in range(T)]
for t in threads: t.start()
for t in threads: t.join()
print(f"GIL={sys._is_gil_enabled()} expected={N*T:,} got={counter:,} lost={N*T-counter:,}")
counter += 1 is three operations: load, add, store. Nothing in the language has ever promised that's atomic. Two runs on every build:
# Python 3.14.10 (main, Nov 11 2026, 00:18:44) [Clang 23.1.3 ]
GIL=True expected=4,000,000 got=4,000,000 lost=0
GIL=True expected=4,000,000 got=4,000,000 lost=0
# Python 3.14.10 free-threading build (main, Nov 11 2026, 00:18:18) [Clang 23.1.3 ]
GIL=False expected=4,000,000 got=1,179,842 lost=2,820,158
GIL=False expected=4,000,000 got=1,333,023 lost=2,666,977
# Python 3.15.2 (main, Nov 11 2026, 00:19:20) [Clang 23.1.3 ]
GIL=True expected=4,000,000 got=4,000,000 lost=0
GIL=True expected=4,000,000 got=4,000,000 lost=0
# Python 3.15.2 free-threading build (main, Nov 11 2026, 00:19:22) [Clang 23.1.3 ]
GIL=False expected=4,000,000 got=952,831 lost=3,047,169
GIL=False expected=4,000,000 got=1,218,868 lost=2,781,132
Both GIL builds were perfect every time. Both free-threaded builds threw away between 2.67 and 3.05 million of the 4 million increments, two-thirds to three-quarters of the work.
The GIL build didn't get this right because the code is correct. It got it right because the interpreter only switches threads at certain points in the bytecode loop, and on this build that timing happens to never land between the load and the store. That's luck, not a guarantee, and the free-threaded build removes the luck. Any module-level counter, any "check if key exists, then set it" on a shared dict, any lazy-init singleton without a lock was always a race. It was just a race that never fired.
The fix is the boring one:
import sys, threading
counter = 0
lock = threading.Lock()
def bump(n):
global counter
for _ in range(n):
with lock:
counter += 1
GIL=True expected=4,000,000 got=4,000,000 lost=0
wall 0.34 s
GIL=True expected=4,000,000 got=4,000,000 lost=0
wall 0.42 s
GIL=False expected=4,000,000 got=4,000,000 lost=0
wall 0.55 s
GIL=False expected=4,000,000 got=4,000,000 lost=0
wall 0.58 s
GIL=True expected=4,000,000 got=4,000,000 lost=0
wall 0.16 s
GIL=False expected=4,000,000 got=1,055,404 lost=2,944,596
wall 0.23 s
Correct on both builds. Look at the price, though: on 3.15.2t the locked version took 0.55–0.58 seconds against 0.23 for the broken one, and the GIL build ran the locked version in 0.34–0.42. A lock held around a single increment serializes your threads again, so the free-threaded build loses its whole advantage plus the overhead. The real fix for hot counters is to not share them: give each thread its own tally and add them up at the end, or use a queue.
The built-in containers do protect themselves. The HOWTO says dict, list and set "use internal locks to protect against concurrent modifications in ways that behave similarly to the GIL," and then immediately recommends using threading.Lock instead of relying on that. It also lists two sharp edges: sharing one iterator between threads can produce "duplicate or missing elements," and reading frame.f_locals from a frame running in another thread "may crash the interpreter." The new built-in frozendict in 3.15 sidesteps the whole problem for read-mostly data. There's more on that in Python's frozendict Is Finally Happening.
Where Threads Beat Processes: Big Shared Data
The prime benchmark flatters multiprocessing: four integers go in and four integers come out, so there's almost nothing to send between processes. Real work usually starts from data that's already in memory: rows loaded from a file, a parsed config or a cache. Sending that to a process pool means pickling it.
Python 3.14 made that cost hard to avoid. Per the 3.14 release notes, "On Unix platforms other than macOS, 'forkserver' is now the default start method for ProcessPoolExecutor (replacing 'fork')." With fork, a worker inherited the parent's memory for free. With forkserver, every argument a worker receives is serialized and copied. So I built two million small dicts in the parent and aggregated them, ten passes per chunk:
import resource, sys, time
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
# 2 million small records, built once in the parent: think "rows loaded from a file".
RECORDS = [{"id": i, "region": i % 50, "amount": (i * 7919) % 10_000} for i in range(2_000_000)]
def total_for(chunk):
out = {}
for _ in range(10): # ten passes: enough CPU work to be worth parallelizing
for r in chunk:
out[r["region"]] = out.get(r["region"], 0) + r["amount"]
return out
def run(pool, workers):
size = len(RECORDS) // workers
chunks = [RECORDS[i * size:(i + 1) * size] for i in range(workers)]
t = time.perf_counter()
with pool(workers) as ex:
parts = list(ex.map(total_for, chunks))
return time.perf_counter() - t
if __name__ == "__main__":
print(f"{sys.version.split()[0]} GIL={sys._is_gil_enabled()} start method=forkserver (3.14+ default on Linux)")
t = time.perf_counter(); total_for(RECORDS); print(f"serial {time.perf_counter() - t:6.2f} s")
print(f"threads x2 {run(ThreadPoolExecutor, 2):6.2f} s")
print(f"processes x2 {run(ProcessPoolExecutor, 2):6.2f} s (chunks pickled to workers)")
print(f"parent peak RSS {resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024:.0f} MB")
3.15.2 GIL=True start method=forkserver (3.14+ default on Linux)
serial 1.37 s
threads x2 1.58 s
processes x2 3.01 s (chunks pickled to workers)
parent peak RSS 632 MB
3.15.2 GIL=True start method=forkserver (3.14+ default on Linux)
serial 1.67 s
threads x2 1.67 s
processes x2 3.04 s (chunks pickled to workers)
parent peak RSS 633 MB
3.15.2 GIL=False start method=forkserver (3.14+ default on Linux)
serial 1.67 s
threads x2 1.04 s
processes x2 3.89 s (chunks pickled to workers)
parent peak RSS 832 MB
3.15.2 GIL=False start method=forkserver (3.14+ default on Linux)
serial 1.80 s
threads x2 1.12 s
processes x2 3.99 s (chunks pickled to workers)
parent peak RSS 830 MB
| 3.15.2 | Serial | Threads x2 | Processes x2 |
|---|---|---|---|
| GIL build | 1.37–1.67 s | 1.58–1.67 s | 3.01–3.04 s |
| Free-threaded | 1.67–1.80 s | 1.04–1.12 s | 3.89–3.99 s |
The process pool was about twice as slow as doing the work serially on both builds. Pickling two million dicts and unpickling them in the workers cost more than the computation itself. Free-threaded threads were the only configuration faster than serial, because they read the parent's list directly with no copy at all.
The memory line is the other half of the trade: the free-threaded parent peaked at about 831 MB against 632 MB for the same records, a 31% premium on dict-heavy data, which is more than the 24% from the simpler test above. On a 2-vCPU box the speedup is modest. On a 16-core box, the gap between "every worker reads the same list" and "every worker gets its own pickled copy" grows with every core you add.
We recommend reading Python's async/await: How It Actually Works and Why You Need It to continue reading our selection of content. If your concurrency is mostly waiting on the network, asyncio is still the better tool, and this explains why.
Python's async/await: How It Actually Works and Why You Need It asyncio is a loop that checks a queue. The event loop mental model behind Python async/await, real code examples, and the mistakes to avoid. SudoSecurity · Santhdium
One Old C Extension Turns the GIL Back On
The free-threaded build has a safety valve. If you import a C extension that hasn't declared it's safe without the GIL, the interpreter turns the GIL back on for the whole process and prints a warning. To see that for myself, I wrote the smallest possible extension the old way, single-phase init with no declaration:
#include <Python.h>
static PyObject *hello(PyObject *self, PyObject *args) {
return PyUnicode_FromString("hi from a module that never declared Py_mod_gil");
}
static PyMethodDef methods[] = {{"hello", hello, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL}};
static struct PyModuleDef mod = {PyModuleDef_HEAD_INIT, "legacy", NULL, -1, methods};
PyMODINIT_FUNC PyInit_legacy(void) { return PyModule_Create(&mod); }
Then I imported NumPy (which ships free-threaded wheels) and that module, checking the GIL state after each:
before import: False
after numpy: False
<frozen importlib._bootstrap>:491: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'legacy', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
after legacy: True
--- PYTHON_GIL=0
before import: False
after numpy: False
after legacy: False
NumPy kept the GIL off. My ten-line module turned it back on for everything, with one RuntimeWarning on stderr that's easy to lose in a container log. PYTHON_GIL=0 (or -X gil=0) forces it off anyway, and the warning's own words, "at your own risk," are the right ones. That module was written assuming the GIL exists.
What does "GIL back on" cost? I ran the benchmark on 3.15.2t with PYTHON_GIL=1:
3.15.2 free-threaded build=True GIL enabled=True cores=2
serial, 4 jobs 3.19 s
threads x2 3.22 s
threads x4 3.47 s
processes x2 1.55 s
That's the worst of both builds: the free-threaded single-thread overhead, plus the GIL contention, so threads come in slower than serial again. One unmarked dependency deep in your tree and your "free-threaded" deploy is quietly the slowest configuration of the lot. Check sys._is_gil_enabled() at startup and log it. Don't assume.
Declaring support in a C extension is a module slot. Here's the same module done properly with multi-phase init:
#include <Python.h>
static PyObject *hello(PyObject *self, PyObject *args) {
return PyUnicode_FromString("hi from a module that declared Py_MOD_GIL_NOT_USED");
}
static PyMethodDef methods[] = {{"hello", hello, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL}};
static PyModuleDef_Slot slots[] = {
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};
static struct PyModuleDef mod = {PyModuleDef_HEAD_INIT, "declared", NULL, 0, methods, slots};
PyMODINIT_FUNC PyInit_declared(void) { return PyModuleDef_Init(&mod); }
hi from a module that declared Py_MOD_GIL_NOT_USED | GIL enabled: False
Adding the slot is the easy part. Making the C code under it actually safe without a lock is the hard part, and that's on the extension author.
Which Packages Are Ready
I asked uv to install a prebuilt wheel only (--only-binary :all:), with no source builds, for a set of common packages on 3.15.2 and 3.15.2t:
package 3.15 3.15t
numpy yes yes
pandas yes yes
scipy yes yes
pydantic yes yes
orjson yes NO
ujson yes yes
pyyaml yes yes
lxml yes yes
msgpack yes yes
cryptography yes yes
psycopg[binary] yes NO
pillow yes yes
uvloop yes yes
grpcio yes NO
zstandard NO NO
bcrypt yes NO
argon2-cffi yes yes
markupsafe yes yes
The scientific stack is ready: NumPy, pandas, SciPy and Pillow all ship free-threaded wheels, and so do Pydantic and lxml. The gaps are in plumbing you might not think about. There's no free-threaded wheel for orjson, psycopg[binary], grpcio or bcrypt, so on 3.15t pip tries a source build. That means a C compiler, and for orjson a Rust toolchain, in your image. zstandard had no 3.15 wheel at all yet, free-threaded or not. This list will change month to month. The community trackers at py-free-threading.github.io and hugovk.github.io/free-threaded-wheels follow it more closely than any article can.
Getting a Free-Threaded Interpreter
- uv:
uv python install 3.15t(or3.14t), thenuv venv -p 3.15t. That's what I used. - Official installers: the macOS and Windows installers from python.org offer it; on macOS for 3.15 it's installed by default.
- Docker: the official
pythonimages on Docker Hub had no free-threaded tags when I checked. I listed every tag matching3.14, and none had atsuffix. You'll need to build your own or copy a uv-managed interpreter into a slim base. - From source:
./configure --disable-gil.
What This Doesn't Cover
- Real applications. These are microbenchmarks on two cores. They show the mechanics, not what your Django app will do. pyperformance and your own load test are the next step.
- Many-core scaling. I couldn't measure contention effects that only show up at 16 or 64 threads.
- asyncio. Event-loop code doesn't benefit from free threading unless you also push CPU work onto threads. That's covered elsewhere.
- Subinterpreters.
concurrent.interpretersin 3.14 is a different route to parallelism with isolated state. It deserves its own comparison. - The JIT. Free threading and the experimental JIT are separate projects, and I didn't test them together.
The Actual Point
Free-threaded Python works. On CPU-bound pure-Python code, threads finally scale with cores, and the memory and data-sharing story beats multiprocessing for the workloads that hurt most. It's officially supported, the major numeric packages are ready, and 3.15's stable ABI makes it easier for the rest to catch up.
But the GIL was doing two jobs, and only one of them was on the label. It serialized your bytecode, and it also covered for a lot of unsynchronized shared state that never failed in practice. Turn it off and those latent races start failing at the rates in the table above. Before you ship a free-threaded build, run your test suite under it with real thread counts, log sys._is_gil_enabled() at startup, and treat every module-level mutable as guilty until proven otherwise.
Sources: Python 3.14 and 3.15 "What's New" pages (including the 3.14 forkserver default), the Python free-threading HOWTO, and PEP 779, all at docs.python.org and peps.python.org. All benchmarks were run by me on python-build-standalone 3.14.10 and 3.15.2 builds via uv. Every code block and output above is reproduced verbatim from the scripts and logs of those runs; the two C modules are original teaching code written against CPython's documented module API.
$ tail -f /forums
Discussion
Comments live on the community forums — sign in there to reply.