What Is the Global Interpreter Lock (GIL) in Python?

The GIL lets only one thread execute Python bytecode at a time in CPython, limiting true multi-threaded CPU parallelism. Learn why it exists and how to work around it.

Published September 18, 2026

The Global Interpreter Lock (GIL) is a mutex in CPython (the standard Python implementation) that allows only one thread to execute Python bytecode at any given moment, even on a multi-core machine.

Common causes

  • CPython's memory management (reference counting) isn't thread-safe by default, so the GIL was introduced to simplify the implementation and avoid race conditions on object reference counts

How to fix it

  • For CPU-bound work, use the multiprocessing module instead of threading — separate processes each get their own Python interpreter and GIL, enabling real parallelism
  • For I/O-bound work (network requests, file access), threading still helps because the GIL is released while waiting on I/O
  • Consider asyncio for high-concurrency I/O-bound workloads without the overhead of OS threads or processes

Example

# CPU-bound: use multiprocessing, not threading
from multiprocessing import Pool
with Pool(4) as p:
    results = p.map(heavy_function, data)

FAQ

Does the GIL mean Python can't do parallelism at all?

It means a single process can't run Python bytecode on multiple cores simultaneously. True parallel CPU work requires separate processes (multiprocessing) or native extensions that release the GIL (like NumPy).

More Python articles