While going through the release notes of Python 3

Arpit Bhayani

Arpit Bhayani

Nov 01, 2023 • 1 min read


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

  1. multi-threads
  2. multi-process
  3. 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

ref: https://lnkd.in/gjqNNYui

⚡ I keep writing and sharing these engineering nuggets, so if you are keen on learning them, follow along.

youtube.com/c/ArpitBhayani

Arpit Bhayani

Principal Engineer II at Razorpay - building Agent Studio, Ex-staff engg at GCP Memorystore & Dataproc, Creator of DiceDB, ex-Amazon Fast Data, ex-Director of Engg. SRE and Data Engineering at Unacademy. I spark engineering curiosity through my no-fluff engineering videos on YouTube and my courses