Python Threading

Picking up pieces of information and see the GIL story is very cumbersome. Different engineers say different things so I started digging.

First thing, we need to understand what is GIL and why it was created:

Watching David B’s Talk and reading “Understanding GIL” I got some important facts:

Python Threads are real and use POSIX(and the equivalents) under the hood. BUT, python has GIL (Global Interpreter Lock) to ensure 1 Thread only at a time.

http://www.dabeaz.com/python/UnderstandingGIL.pdf

This means, that even if I have several CPUs that can operate together to parallel — GIL prevents it (except I/O, which can be parallel). So you’d better go one threaded unless you have I/O operations — otherwise, context switching makes it worth.

This is a good reason to use Python3 (because of the GIL enhancements).

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.