What is the GIL in Python?

The GIL (Global Interpreter Lock) is a lock inside CPython, the standard Python, that allows only one thread to run Python bytecode at a time. It keeps memory management simple and safe.

Because of the GIL, several threads doing heavy calculation do not run in parallel on different CPU cores. But it is released while a thread waits for files, network or database, so threads still work well for such waiting tasks.

Task typeBetter choice
Waiting for network, files, database (I/O bound)threading or asyncio
Heavy calculation (CPU bound)multiprocessing, where each process has its own interpreter and GIL

Python 3.13 also added an experimental build that can run without the GIL, but the normal build still has it. Other implementations such as Jython do not have a GIL.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.