Python · The language, not just syntax

What is the GIL and what are its practical consequences?

HardgilcpythonconcurrencyUpdated Oct 2026
Quiz this track

Short answer

The GIL is a CPython lock that allows only one thread to execute Python bytecode at a time. It makes memory management simpler and single-threaded code fast, but prevents parallel CPU-bound Python threads.

The GIL is an implementation detail of CPython, not part of the language specification. It protects interpreter state, especially reference counts, from concurrent mutation. A thread holds the GIL while running bytecode and releases it periodically and during blocking I/O.

python
from concurrent.futures import ThreadPoolExecutor

def cpu_work(n):
    return sum(i * i for i in range(n))

with ThreadPoolExecutor(max_workers=4) as pool:
    results = list(pool.map(cpu_work, [2_000_000] * 4))

print(results)
Four CPU-bound threads still contend for one GIL, so this does not use four cores. Processes or native code are required for CPU parallelism.

What it does and does not block

  • CPU-bound Python threads do not run in parallel and add scheduling overhead
  • I/O-bound threads still help because the GIL is released during blocking calls
  • C extensions can release the GIL, so NumPy and similar libraries achieve real parallelism
  • The GIL does not make your data structures thread-safe; explicit locks are still required

CPython 3.13 introduced an experimental free-threaded build without the GIL, and support is evolving across releases. It is not the default, and extension compatibility and single-thread performance must be evaluated before adopting it. Do not tell an interviewer the GIL is gone in general production Python.

The GIL is not a substitute for locking. Two threads can still interleave at bytecode boundaries and corrupt shared state, so use locks, queues or immutable handoffs.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1Why does the GIL exist in CPython?
  2. 2When do threads still improve performance despite the GIL?
  3. 3Is the GIL part of the Python language?
  4. 4What is the status of free-threaded CPython?

Say it in the interview

The GIL is a CPython lock that lets only one thread run Python bytecode at a time. It simplifies reference counting and keeps single-threaded performance strong, but CPU-bound threads cannot use multiple cores. Threads still help for I/O because the GIL is released during blocking calls, and NumPy can release it for native work. It also does not remove the need for locks around shared state.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Python mock interview and get scored feedback on depth, clarity and confidence.