Full Byte Developer.

Python GIL: why threads are not truly parallel

On default CPython, one thread runs bytecode at a time. Threads still help for I/O; free-threading stays optional.

Published here , updated · 8 sources

On default CPython builds, the global interpreter lock means only one thread runs Python bytecode at a time, so CPU-bound pure-Python threads do not get true multi-core speedup [1][3]. Threads still help when work is mostly waiting on I/O, because the GIL is released during those waits. Free-threaded builds exist, but they stay optional.

Quick start: print whether your build still has the GIL

bash
python3 - <<'PY'
import sys, sysconfig
print("version:", sys.version.split()[0])
print("Py_GIL_DISABLED:", sysconfig.get_config_var("Py_GIL_DISABLED"))
print("has _is_gil_enabled:", hasattr(sys, "_is_gil_enabled"))
if hasattr(sys, "_is_gil_enabled"):
    print("gil enabled now:", sys._is_gil_enabled())
PY

Captured on this host:

text
version: 3.12.3
Py_GIL_DISABLED: None
has _is_gil_enabled: False

That is a classic GIL build. Free-threaded builds advertise themselves in sys.version with free-threading build, expose sys._is_gil_enabled(), and set Py_GIL_DISABLED to 1 [4].

Time CPU-bound pure Python on two threads

bash
python3 - <<'PY'
import threading, time

N = 8_000_000

def cpu_work():
    x = 0
    for i in range(N):
        x += i
    return x

t0 = time.perf_counter()
cpu_work()
cpu_work()
print(f"CPU sequential two runs: {time.perf_counter() - t0:.3f}s")

t0 = time.perf_counter()
th1 = threading.Thread(target=cpu_work)
th2 = threading.Thread(target=cpu_work)
th1.start(); th2.start()
th1.join(); th2.join()
print(f"CPU two threads: {time.perf_counter() - t0:.3f}s")
PY

Captured on the same host (one trial). Sandbox capture on the review host; re-run on your box before you treat the numbers as a lab result.

text
CPU sequential two runs: 0.376s
CPU two threads: 0.401s

Two threads did not finish in about half the sequential time. Here they took slightly longer. Label that as one machine, one build, one day. Re-run before you quote your own numbers. Glossary wording: the GIL assures that only one thread executes Python bytecode at a time [1]. Threading docs advice for CPU-bound work on GIL builds: use multiprocessing or concurrent.futures.ProcessPoolExecutor [3].

Time overlapping I/O waits

bash
python3 - <<'PY'
import threading, time

def io_work():
    time.sleep(0.4)

t0 = time.perf_counter()
io_work(); io_work()
print(f"IO sequential two sleeps: {time.perf_counter() - t0:.3f}s")

t0 = time.perf_counter()
th1 = threading.Thread(target=io_work)
th2 = threading.Thread(target=io_work)
th1.start(); th2.start()
th1.join(); th2.join()
print(f"IO two threads: {time.perf_counter() - t0:.3f}s")
PY

Captured:

text
IO sequential two sleeps: 0.800s
IO two threads: 0.401s

Overlapping waits finished near one sleep duration. Glossary: the GIL is always released when doing I/O; some extensions also release it for heavy C work such as compression or hashing [1]. Do not turn that into a universal "threads are 2x faster" law.

classic CPython GIL Thread A holds GIL, runs bytecode Thread B waits for GIL Thread C waits for GIL I/O path blocking I/O releases the GIL so waits can overlap on one process [1][3]

Dark diagram of Thread A holding the GIL to run bytecode while Thread B and Thread C wait for the lock. The lower I/O band shows blocking I/O releasing the GIL so waits can overlap on one process without true multi-core CPU speedup.

Date the free-threading status from python.org

PEP 703 made an optional free-threaded CPython build possible in 3.13 via --disable-gil [5]. The official howto: starting with 3.13, free-threaded builds can run threads in parallel on available cores; macOS and Windows installers can optionally ship those binaries; third-party extension modules may re-enable the GIL [4]. Runtime can still force the GIL with PYTHON_GIL or -X gil [4].

PEP 779 (Final, Python-Version 3.14, resolution 16-Jun-2025): Phase II means the free-threaded build is officially supported but still optional. Phase III (making it the default) is explicitly left for a future PEP [6]. Threading docs: as of 3.13, free-threaded builds can disable the GIL, but the feature is not available by default [3].

Pick the API that matches the bottleneck

For pure-Python CPU work on a classic GIL build, prefer processes via ProcessPoolExecutor rather than more threads [3]. Vocabulary for the review: overlapping waits are concurrency; same-time multi-core CPU progress is parallelism, as in concurrency vs parallelism in plain words.

Mistakes that show up in PR reviews

Adding more threads to a pure-Python CPU hot path and calling the result "parallel." Measure wall time against a sequential baseline first [1][3].

Treating free-threaded Python as already the default on every laptop. Check Py_GIL_DISABLED and the howto markers [4][6].

Using threads for CPU work when the docs already point at multiprocessing [3].

Confusing asyncio Tasks with multi-core speedup. Tasks still run on one event loop thread unless you offload elsewhere. See Python create_task vs await and Python async def is lazy until you await.

Claiming all extensions release the GIL. Many do for I/O; verify the extension you ship [1][7].

Depth: what the lock actually protects

The glossary describes the GIL as a mutex that protects access to Python objects and prevents multiple threads from executing Python bytecode at once [1]. The C API docs cover how extension authors acquire and release the lock around non-Python work [7]. That is why a compression library written in C can use multiple cores inside one call while your pure-Python loop cannot.

Production systems that outgrew one runtime's concurrency story often move hot paths into languages with different ownership models. Discord's public engineering writeup on scaling with Rust is one company example of that pressure; it is not a claim that you must leave Python to finish this page [8]. For a Go-side comparison of structure versus cores, see goroutines vs Python coroutines.

Re-run the demos before you quote numbers

Change N, change the host, or change the Python patch version and the CPU timings move. Keep the I/O demo near fixed sleeps so the overlap story stays obvious. When you write a design note, paste both the GIL probe and the two timing blocks so reviewers see the build class and the measured shape on the same day [1][3][4].

If someone asks "should we enable free-threading tomorrow," answer with the PEP 779 phase line: supported, optional, default still undecided [6]. Then point at the extension modules you depend on, because those packages may force the GIL back on even inside a free-threaded build [4].

Threads still share one process

Threads share an address space. The GIL limits bytecode concurrency; it does not invent process isolation. Shared mutable lists still need locks or queues even when the GIL serializes bytecode steps [3]. Processes give separate interpreters and separate heaps at the cost of pickling and IPC. Prefer that cost when the profiler shows CPU, not when the profiler shows wait.

A practical review question: "Are we overlapping waits, or trying to finish CPU work sooner?" Waits point at threads or asyncio. CPU points at processes, native extensions, or a verified free-threaded build [1][3][4]. Write the answer in the PR description so the review stays on the right layer.

What "released around I/O" means in practice

When a thread hits a blocking read, sleep, or similar wait, CPython can release the GIL so another thread runs bytecode [1][7]. That is why two time.sleep calls overlap. A tight pure-Python loop never reaches that release point, so a second thread mostly waits for the lock. Extensions that do heavy C work can also release the lock for the duration of the C call; that is an extension property, not a property of every import [1][7].

If your hot path is numpy, hashing, or compression inside a well-behaved extension, threads may help for that slice. If your hot path is a Python for loop over Python objects, measure before you multiply workers.

Browse the Dev explainers topic.

Send this to the friend who added threads to Python code and saw no speedup.

Several teal thread ribbons approach a single glowing amber mutex ring around one central core, with only one ribbon passing through at a time while others wait, and a side tunnel letting one ribbon slip around the ring, on a dark navy field with no typography.
One bytecode core at a time. Threads still help when they spend time waiting on I/O.

Keep this guide

By Full Byte Developer

Filed under Dev explainers

Questions about this guide

Are Python threads useless?

No. The threading docs say threading is still appropriate for many I/O-bound tasks. The GIL is released around blocking I/O, so overlapping waits can finish sooner than running those waits one after another.

Is free-threaded Python the default install now?

No. Free-threaded builds exist from 3.13 and are officially supported but still optional as of PEP 779 (Phase II for 3.14). Phase III (default) is left for a future decision. Most installs still use a classic GIL build unless you chose a free-threading binary.

How do I know if my build is free-threaded?

Official howto: python -VV or sys.version contain free-threading build; sys._is_gil_enabled() reports whether the GIL is active in the running process; sysconfig.get_config_var("Py_GIL_DISABLED") == 1 means the build supports free threading.

Sources

Next in this stack