Global Interpreter Lock (GIL)

say it: “GLOH-bul in-TUR-pruh-ter lok” /ˈɡloʊbəl ɪnˈtɜrprətər lɑk/ or “GIL” /ˈɡɪl/

Lets only one thread run Python code at a time in standard Python.

What is the GIL?

The GIL (Global Interpreter Lock) lets only one thread run Python code at a time in standard Python. Threads still help while waiting on files or networks; for heavy calculations use multiprocessing. Newer Pythons offer a build without it.

# Threads: good for waiting (downloads, web requests)
# Processes: good for crunching (image resizing, big math)
from multiprocessing import Pool

Level: Master · More Python terms at this level

Updated