The GIL's most fundamental role is to safeguard Python's reference counting, preventing race conditions that would corrupt object reference counts, leading to memory leaks or crashes from premature deallocation.
Open the full topic