Skip to content
0:00 / 0:00

#gil#cpython#multithreading

Understanding the Python GIL

David Beazley

17K subscribers • 4 videos on Hallway

YouTube
  • Recommended by 6 people: 4 on Hacker News and 2 curated lists.
  • A classic. People kept recommending it from 2013 to 2022.
  • Presented by David Beazley

Intermediate. Assumes working knowledge.

127K views14 years ago6 recommendations

Programming languagesSystems programmingPythonConcurrency and parallelismPerformance and optimization

David Beazley explains the mechanics of the Python Global Interpreter Lock and its surprising performance impacts on multicore systems.

Dave Beazley's presentation from PyCon'2010 in Atlanta Georgia. This is a mirror of the original presentation hosted at blip.tv/pycon-us-videos-2009-2010-2011/pycon-2010-understand…. David Beazley teaches intense in-person Python Programming and Computer Science courses in Chicago. Details at dabeaz.com/courses.html

Why it's here

6 people recommend this

What people say. Widely recommended as the definitive, classic explanation of the Python Global Interpreter Lock and its multicore performance issues.

famousactresson Hacker News • Recommends

On “Code is not Literature”

"The point of such a presentation is to take a piece of code that the presenter has understood deeply and for them to help the audience understand the core ideas..." I do get lots of value out of that. My favorite example is Beazley's GIL talk: link to this video

programming-talkscurated list on GitHubRecommends

Under “Python”

Understanding the Python GIL 00:46:10 by **David Beazley** (2012)

Coding Interview Universitycurated list on GitHubRecommends

Under “Even More Knowledge”

Understanding the Python GIL (2010)

Luyton Hacker News • Recommends

On “Python's Hardest Problem (2012)”

"I never actually got around to learning -- or even thinking about!-- what exactly the GIL is" David Beazley does a good job on explaining the GIL. There are multiple videos of his GIL talks on YouTube. This one, for instance: link to this video He has a page about this at link

devxpyon Hacker News • Recommends

On “Code with Mu: a simple Python editor for beginner programmers”

David probably isnt the best guy for that. But here's one of the famous ones on GIL. link to this video Beware though, his talks are known to be devastating to the programmer, resulting in serious head injuries, trauma, headaches and other fun stuff.

gshulegaardon Hacker News • Recommends

On “How to choose the right Python concurrency API”

I am not expert, and this might be dated information, but historically there is a "thrashing" introduced between the GIL and OS scheduled threads which has surprising performance implications. David Beazley does a much better illustrating the nuances than I ever could: link to this video Including a wild phenomenon where a threaded Python program's performance can degrade by increasing number of CPU cores available to a system. Coroutines avoid this by not requiring individual thread scheduling by the OS. So they effectively release the GIL like threads on IO but avoid OS level thread switching.

zerktenon Hacker News • Mentions

On “Problems I Have with Python”

…ow to go about integrating C/C++ code. Many people complaining about the GIL (and the like) have some naive microbenchmark, don't understand the trade-offs/limitations of their runtime etc. That doesn't mean critique isn't important and required, but it's going to be better when it's properly researched and improves on the body of work out there ( link to this video ). > Transpiling it to another language like Google did, shows that the underlying technology is not worth much. How is this any general indicator of the worth of the language? It shows for some cases, that Google thought this was a worthwhile investment. Google has experimented for a long time with ways to improve how Python code can be ru…

gshulegaardon Hacker News • Mentions

On “The multiprocessing module in Python”

I would recommend you use coroutines rather than multiprocessing.dummy for balancing blocking operations (like IO). I believe multiprocessing.dummy is just a wrapper for threading which has context switching overhead 1. Python3 has asyncio as part of the stdlib but for Python2 there are a variety of coroutine libraries out there (I think the most widely recognized being gevent). 1 link to this video

gshulegaardon Hacker News • Mentions

On “Async Python is not faster”

…me the GIL > No it's not, just use threads. I just wanted to expand on this a little to describe some of the downsides to threads in Python. Multi-threaded logic can be (and often is) slower than single-threaded logic because threading introduces overhead of lock contention and context switching. David Beazley did a talk illustrating this in 2010: link to this video He also did a great talk about coroutines in 2015 where he explores threading and coroutines a bit more: link In workloads that are often "blocked" like network calls our I/O bound work loads, threads can provide similar benefits to coroutines but with overhead. Coroutines seek to provide the same benefit without as much overhead (no lock…

rvanlaaron Hacker News • Mentions

On “Progress on No-GIL CPython”

There's a GIL presentation 1 from 2010 which shows Python 3.2 on a 1 CPU machine was faster than on a dual core. In all, there might be reason to expect GILless python to be faster single core in certain scenario's. 1 link to this video