What is Python's Global Interpreter Lock, and how does it shape the way you parallelize work in Python?
technical-conceptual · Mid level · software-engineering
What the interviewer is really asking
Assesses whether the candidate understands why CPython threads don't give CPU parallelism and can pick the right concurrency model (threading, asyncio, multiprocessing) for a given workload rather than reciting a definition.
What to say
- Define it concretely: the GIL is a mutex in CPython that lets only one thread execute Python bytecode at a time, so threads can't run Python-level CPU work in parallel on multiple cores.
- Map the model to the workload: use asyncio or threading for I/O-bound work (the lock is released while waiting on the network or disk), and multiprocessing for CPU-bound work because separate processes each get their own interpreter and sidestep the GIL.
- Show currency: note the GIL is not in the language spec — it's a CPython implementation detail. Python 3.13 added an experimental free-threaded build (PEP 703), and PEP 779 promoted it to officially supported in 3.14, at a single-threaded cost of roughly 5-10 percent today.
What to avoid
- Claim the GIL makes Python single-threaded — you can have many threads; the constraint is only that one runs Python bytecode at a time.
- Recommend threading to speed up a pure-CPU number-crunching loop; the GIL serializes it and you get no speedup.
- Present the GIL as a fixed law of the language rather than a removable CPython implementation choice.
Example answers
Strong: On a service that fanned out hundreds of outbound HTTP calls, I moved the calls to asyncio with aiohttp and cut wall-clock latency about 4x, because the GIL is released during the network waits so concurrency was real there. Later I had a CPU-bound image-resize step that didn't speed up under threads, so I switched it to a multiprocessing pool to actually use the cores.
Weak: The GIL is a lock so Python can only do one thing at a time. To go faster you just add more threads and it spreads across cores automatically.