What is GIL?

GIL (Global interpreter Lock) is a mutex. Mutex is an mutual exclusion object used to prevent from two threads or more, to access the same piece of code.  This piece of code  also called ‘critical section’.

So GIL is Python’s way to ensure only one thread is running the code at any given time. It serializes the access to the interpreter and ensures that each thread gets exclusive access to the interpreter internals when running.

Continue reading