With the python GIL, only one thread at a time is in control of the interpreter.1

The GIL is part of Python’s memory management which counts variable references to keep track where you are in the program. Once this count goes down to zero, the thread is “released” or purged from memory.

The reference count has to be locked down to avoid it being affected by race-conditions.

>>> import sys
>>> a = []
>>> b = a
>>> sys.getrefcount(a)

See also: python-core-threading


  1. What Is the Python Global Interpreter Lock (GIL)? – Real Python