GIL
What's the hassle and... should I care?
GIL often appears as a scary, obscure gizmo. Misunderstanding of this aspect of Python may lead to suboptimal architectural choices. I invite you to see my attempt at explaining the GIL and its implications, as well as providing pointers for how to deal with the GIL in specific situations.
There have been (and still are), of course, attempts to get around the GIL - or get rid of it altogether. I hope to give some light to these works.
By providing a comprehensive overview of today's GIL in CPython, this presentation aims to help make better design choices - be it choosing a concurrency/parallelism model, Python implementation to use - or even whether or not to drop Python entirely.
Presented at
- PyCon CZ 2016 (slides - PDF, 5.16 MiB)
- PyCon PL 2016 (slides - PDF, 3.94 MiB)
- PyCon Estonia 2023 (slides - PDF, 2.3 MiB)
- PyStok #62 (slides - PDF, 2.3 MiB, PL)
- PyWaw #109 (slides - PDF, 2.3 MiB)
- PyRa 29.02.2024 (slides - PDF, 2.4 MiB, PL)
- PyCon SK 2024 (slides - PDF, 2.4 MiB)
- Pykonik - Tech Talks #69 (slides - PDF, 2.4 MiB)
- PyCon Italia 2024 (slides - PDF, 2.4 MiB)
- Helsinki Python 22.10.2024 (slides - PDF, 2.3 MiB)
Links
De-GILing attempts
(not an exhaustive list):
- PEP 703 – Making the Global Interpreter Lock Optional in CPython
- subinterpreters for parallelization
- GILectomy
- The Gilectomy - Larry Hastings, EuroPython 2016
- GILectomy repository
- python-safethread - 2008
- "Free-threading" patch - 1996
- An Inside Look at the GIL Removal Patch of Lore - David Beazley, 2011
The GIL code
- in newest Python:
- in Python 2.7: part of
ceval.h
Bibliography
- Python's Infamous GIL - Larry Hastings, EuroPython 2015
- In Search of the Perfect Global Interpreter Lock - David Beazley, RuPy 2011
- Embracing the Global Interpreter Lock (GIL) - David Beazley, 2011
- Understanding the Python GIL - David Beazley, PyCon 2010
- Inside the Python GIL - David Beazley, 2009