This post is part of the blogpost series explaining coroutines, how they implemented in various programming languages and how they can make your life better:...| dmitrykandalov.com
In CPython, the global interpreter lock, or GIL, is a mutex that protects access to Python objects, preventing multiple threads from executing Python bytecodes at once. The GIL prevents race conditions and ensures thread safety. A nice explanation of how the Python GIL helps in these areas can be found here. In short, this mutex is necessary mainly because CPython's memory management is not thread-safe. | wiki.python.org