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) 3
See also: python-core-threading