Python is becoming more parallel with Free-Threading and Subinterpreters. Both approaches allow threads to run in parallel without the restriction of a single GIL. The downside is that parallelization comes with a safety tax: Free-threading adds a lock per object and subinterpreters typically involve pickling and copying data between interpreters to ensure isolation. This has a negative impact on performance with both CPU and memory overheads. This talk is about PEP795, which proposes to add immutability to Python. It allows threads to share data without the risk of data races. This enables different optimisations: on free-threaded Python, interpreter-level synchronisation is no longer needed to ensure safe access to shared data structures (think PEP frozendict but for any type), it allows multiple subinterpreters to directly share objects without copying, and it improves GC performance by simplifying cycle detection.
We will present the design and rationale for immutability in Python, the API for creating and managing immutable state, decorators for communicating immutability in code, as well as opting out of immutability where necessary. We will also discuss our prototype implementation on-top of Python 3.15 and demonstrate how immutable sharing across sub-interpreters improves performance and compare the speed of freezing (the act of making objects immutable) to pickling and unpickling.
This is an updated version of our immutability talk at EuroPython'26 based on feedback from the Python community.