The GIL primarily protects CPython's reference counting mechanism, preventing race conditions where multiple threads simultaneously modify an object's `ob_refcnt`, which could lead to memory leaks or crashes.
Open the full topic