Interview Question

What is GIL in Python?

The CPython GIL serializes Python bytecode in standard builds, not all concurrent work.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

In standard GIL-enabled CPython builds, the Global Interpreter Lock allows one thread to execute Python bytecode at a time. • Threads can still overlap while waiting for I/O or when extension code releases the GIL. • The GIL does not make application data automatically thread-safe. • Free-threaded CPython builds can disable the GIL, but that is not the default configuration everywhere.

💡 Simple Example

import threading print(threading.current_thread().name)

Output

MainThread

⚡ Quick Revision

The CPython GIL serializes Python bytecode in standard builds, not all concurrent work.