October 2018
Beginner to intermediate
466 pages
12h 2m
English
In order to efficiently manage memory, garbage collection, and calls to machine code in native libraries, Python has a utility called the global interpreter lock, or GIL. It's impossible to turn off, and it means that threads are useless in Python for one thing that they excel at in other languages: parallel processing. The GIL's primary effect, for our purposes, is to prevent any two threads from doing work at the exact same time, even if they have work to do. In this case, doing work means using the CPU, so it's perfectly okay for multiple threads to access the disk or network; the GIL is released as soon as the thread starts to wait for something. This is why the weather example worked.
The GIL is highly disparaged, ...