midPython
Global Interpreter Lock (GIL)
Updated May 4, 2026
Short answer
A mutex that prevents multiple threads from running bytecode at once.
Deep explanation
Ensures thread safety in CPython by allowing only one thread to control the interpreter. Impacts CPU-bound multi-threading performance.
Real-world example
Understanding why multi-threaded Python doesn't speed up math-heavy tasks.
Common mistakes
- Assuming Python can't do any concurrency (it can via multiprocessing or async).
Follow-up questions
- Does it affect I/O?