GIL (Global Interpreter Lock)
GIL (Global Interpreter Lock) — The GIL is a mutex that protects access to Python objects, preventing multiple threads from executing Python bytecode simultaneously. The Global Interpreter Lock (GIL) simplifies CPython's memory management by ensuring only one thread executes Python code at a time. This makes single-threaded programs faster but limits CPU-bound multithreading. For CPU-bound tasks, use `multiprocessing` instead of `threading`. The GIL does not affect I/O-bound operations and some Python implementations (Jython, IronPython) don't have a GIL. This term relates to the Built-in Functions category of the reference. You will meet gil (global interpreter lock) in practice when working with APIs such as print(), len(), range(), type(). Related terms: Decorator, Generator, Context Manager, Duck Typing, List Comprehension, Mutable vs Immutable. Understanding gil (global interpreter lock) makes the rest of the Python documentation noticeably easier to follow, because the concept recurs across function references, guides, snippets, and error messages you will meet in real projects.