While going through the release notes of Python 3.12, I stumbled upon something interesting … sub-interpreters ⚡
Python subinterpreters are separate, isolated versions of the Python interpreter running in the same process as the main interpreter. Thus, Python supports 3 types of concurrency
- multi-threads
- multi-process
- multi-interpreters
Think of each interpreter as an isolated execution environment of Python within the same process, and because they are part of the same process they can exchange messages using OS Pipes.
Python 3.12 has introduced a per-interpreter GIL, which means that sub-interpreters may now be created with a unique GIL per interpreter allowing Python programs to take full advantage of multiple CPU cores.
Read more about sub-interpreters here - https://lnkd.in/gZjGtGMz
⚡ I keep writing and sharing these engineering nuggets, so if you are keen on learning them, follow along.
youtube.com/c/ArpitBhayani