Contribute Media
A thank you to everyone who makes this possible: Read More

Let's talk about GIL!

Translations: en


I will be talking about Global-Interpreter-Lock (GIL) in Python. It's a mutex that prevents multiple native threads from running in parallel. In essence, this says that a python program cannot do more than one thing at once via threading. There is a lot of misconception in a lot of Python Programmers regarding Global Interpreter Lock. Most of them think its the worst part of Python.

I will try to demonstrate how it actually works and how we can leverage multiple CPU cores for multithreading for I/O and CPU Bound task using C-Extensions. I will also show some comparisons with different implementations of Python and the presence or absence of GIL in those, to answer questions like, why we can't just remove it from CPython and solve all our problems or why Jython performs better in Multithreading for CPU Bound task.


Improve this page