Updated November 2026: covers the free-threaded CPython builds (PEP 703) in Python 3.13 and 3.14, how to check whether the GIL is active, a CPU-bound thread benchmark you can run yourself, and an equivalent Rust program. It ends with a practical guide to choosing between free-threaded Python, Rust, or both.
For decades, CPython's Global Interpreter Lock (GIL) has meant that only one thread runs Python bytecode at a time. CPU-bound work therefore needed multiprocessing or a compiled extension. Rust took the opposite approach: native threads with no runtime lock, and data races ruled out at compile time. Free-threaded Python changes the comparison, so this guide looks at what really changed and what did not.
What "No-GIL" Python Actually Is
- PEP 703 added an optional build of CPython without the GIL. It first shipped as an experimental build in Python 3.13 (often installed as
python3.13t). - In Python 3.14, the free-threaded build became officially supported (PEP 779), but it is still a separate build. The default
pythonon most systems still has the GIL. - If a C extension does not declare that it is safe to run without the GIL, importing it turns the GIL back on, and Python prints a warning. You can override this with
PYTHON_GIL=0or-X gil=0, but that is at your own risk. - Single-threaded code runs somewhat slower on the free-threaded build. The overhead was noticeable in 3.13 and was reduced in 3.14, so measure your own workload.
Step 1: Check Which Build You Are Running
import sys
import sysconfig
build_supports_free_threading = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
gil_enabled = sys._is_gil_enabled() if hasattr(sys, "_is_gil_enabled") else True
print(f"Python {sys.version.split()[0]}")
print(f"Free-threaded build: {build_supports_free_threading}")
print(f"GIL active right now: {gil_enabled}")
On a standard build this prints Free-threaded build: False. On a free-threaded build with no GIL-requiring extensions loaded, it prints True and GIL active right now: False. With uv, you can try one without touching your system Python: uv run --python 3.13t python check.py.
Step 2: A CPU-Bound Thread Benchmark
This script counts primes in pure Python, once with one worker thread and once with up to eight. On a GIL build, the threads take turns, so you should see no real speed-up:
import os
import time
from concurrent.futures import ThreadPoolExecutor
def count_primes(limit: int) -> int:
"""Deliberately CPU-bound pure-Python work."""
count = 0
for n in range(2, limit):
if all(n % d for d in range(2, int(n**0.5) + 1)):
count += 1
return count
def run(workers: int, jobs: int = 8, limit: int = 60_000) -> float:
start = time.perf_counter()
with ThreadPoolExecutor(max_workers=workers) as pool:
results = list(pool.map(count_primes, [limit] * jobs))
assert len(set(results)) == 1
return time.perf_counter() - start
if __name__ == "__main__":
cpus = os.cpu_count() or 1
one = run(workers=1)
many = run(workers=min(8, cpus))
print(f"1 thread : {one:.2f}s")
print(f"{min(8, cpus)} threads: {many:.2f}s (speed-up x{one / many:.1f})")
On our 8-vCPU Linux test machine, the standard 3.13 build took about the same time with 1 or 8 threads (x1.0). The free-threaded 3.13 build was slower with a single thread (0.52 s vs 0.37 s) but about 4x faster with 8 threads. Treat these numbers as an example, not a benchmark. Results depend on your CPU, your Python version and your workload.
Step 3: Free Threading Means You Need Locks
Without the GIL, you can no longer rely on it to hide races in shared state. CPython still keeps its own internals (such as list and dict operations) from corrupting memory. But a read-modify-write such as counter += 1 is not atomic, so protect shared state explicitly:
import threading
from concurrent.futures import ThreadPoolExecutor
counter = 0
lock = threading.Lock()
def add_many(n: int) -> None:
global counter
for _ in range(n):
with lock: # without this lock, updates can be lost
counter += 1
with ThreadPoolExecutor(max_workers=4) as pool:
for _ in range(4):
pool.submit(add_many, 100_000)
print(counter) # always 400000 with the lock
The Same Work in Rust
Rust gives you real parallel threads with no interpreter overhead. The compiler rejects code that shares mutable data without synchronisation:
use std::thread;
fn count_primes(limit: u32) -> u32 {
(2..limit)
.filter(|&n| (2..=((n as f64).sqrt() as u32)).all(|d| n % d != 0))
.count() as u32
}
fn main() {
let jobs = 8;
// Scoped threads: the compiler proves no data race can occur.
let results: Vec<u32> = thread::scope(|s| {
let handles: Vec<_> = (0..jobs)
.map(|_| s.spawn(|| count_primes(60_000)))
.collect();
handles.into_iter().map(|h| h.join().unwrap()).collect()
});
println!("{:?}", results);
}
Built with rustc -O, this runs the same prime-counting jobs many times faster than either Python build, because it is compiled machine code. The price is a slower edit-compile cycle, a steeper learning curve, and a smaller ecosystem for data science and scripting.
Comparison Table
| Aspect | Free-threaded Python (3.13t / 3.14t) | Rust |
|---|---|---|
| Parallel CPU threads | Yes, on the free-threaded build | Yes |
| Raw single-thread speed | Interpreter speed (slightly slower than the GIL build) | Native, typically far faster |
| Data-race protection | Runtime: you add locks yourself | Compile time: ownership and Send/Sync checks |
| Ecosystem readiness | Growing; some C extensions still re-enable the GIL | Mature for systems work; smaller for data science |
| Development speed | Fast to write and change | Slower at first; strict compiler |
| Deployment | Needs a separate interpreter build | Single static binary |
When to Choose Each
- Stay on standard Python if your work is mostly I/O-bound (web apps, API calls).
asyncioand normal threads already handle that well. - Try free-threaded Python if you have CPU-bound pure-Python code that splits naturally into threads, and all your dependencies support free threading.
- Choose Rust for latency-critical services, CLI tools that ship as one binary, or hot loops where even parallel Python is too slow.
- Use both: write the hot path in Rust and expose it to Python with PyO3 and
maturin. Many popular Python libraries are built this way.
FAQ: Python No-GIL vs Rust
Is the GIL removed from normal Python?
No. Free threading is a separate build. The default CPython build still has the GIL.
Will free-threaded Python make my code faster?
Only if it is CPU-bound and runs in several threads. Single-threaded code may run slightly slower.
Do I still need multiprocessing?
On a GIL build, yes, for CPU-bound parallelism. On a free-threaded build, threads can often replace it, and they share memory without pickling.
Is Rust always faster?
For pure computation, usually yes. For I/O-bound work or code built on NumPy, Polars and similar libraries, the difference is often small.