Running Python Parallel Applications with Sub Interpreters
Python 3.12 introduced a new API for “sub interpreters”, which are a different parallel execution model for Python that provide a nice compromise between the true parallelism of multiprocessing, but with a much faster startup time. In this post, I’ll explain what a sub interpreter is, why it’s important for parallel code execution in Python and how it compares with other approaches. Python’s system architecture is roughly made up of three parts: To learn more about this, you should read the “Parallelism and Concurrency” chapter of my book CPython Internals. Since Python 1.5, there has been a C-API to have multiple interpreters, but this functionality was severely limited by the GIL and didn’t really enable true parallelism. As a consequence, the most commonly used technique for running code in parallel (without third party libraries) is to use the multiprocessing module. In 2017, CPython core developers proposed to change the structure of interpreters so that the they were better isola
Running Python Parallel Applications with Sub Interpreters Python 3.12 introduced a new API for "sub interpreters", which are a different parallel execution model for Python that provide a nice compromise between the true parallelism of multiprocessing, but with a much faster startup time. In this post, I'll explain what a sub interpreter is, why it's important for parallel code execution in Python and how it compares with other approaches. What is a sub interpreter? ¶ Python's system architecture is roughly made up of three parts: A Python process, which contains one or more interpreters
related reading
- Global interpreter lock - Wikipediaen.wikipedia.org
- PEP 703 – Making the Global Interpreter Lock Optional in CPython | peps.python.orgpeps.python.org
- Multithreading and Multiprocessing in 10 Minutes | Towards Data Sciencetowardsdatascience.com
- What Is the Python Global Interpreter Lock (GIL)? – Real Pythonrealpython.com
- Python behind the scenes #13: the GIL and its effects on Python multithreadingtenthousandmeters.com
- Pipeline-Parallelism: Distributed Training via Model Partitioningsiboehm.com
- Reading 14: Concurrencyweb.mit.edu
- To Thread or Not to Thread: An In-Depth Look at Ruby’s Execution Models - Shopifyshopify.engineering
- Introduction · Crafting Interpreterscraftinginterpreters.com
- Multi Core Programming and Threadsimomath.com
- Glossary — Python 3.14.6 documentationdocs.python.org
- Why Learn Python Concurrency – SuperFastPythonsuperfastpython.com