Dynamically Checked Deep Immutability in Python
summary
Adds deep immutability to CPython 3.15 via 7,000 lines of runtime code, an atomic refcount for immutable objects, and write barriers inserted at 148 hot sites; passes the full CPython test suite (~600,000 lines) plus 3.6k new tests and measures a 3.6% geomean single-thread slowdown. Implements freezability (per-object opt‑out) and five forms of detachment to avoid global propagation, enables zero-copy sharing across sub-interpreters, and shows freezing is faster than copying for benchmarked workloads.
AI-written summary · about
chapters (13)
- 0:00Deep immutability in Python
- 1:45Motivation for deep immutability
- 3:08Sub-interpreters and immutability
- 4:52Design goals and restrictions
- 6:17Freeze propagation in Python
- 7:43Challenges with Python objects
- 8:48Freezability and detachment
- 10:12Implementation details in CPython
- 11:59Backwards compatibility evaluation
- 12:42Performance impact results
- 13:45Sub-interpreter sharing performance
- 14:48Next steps and engagement
- 15:11Q&A
related talks
31mIntroducing Immortal Objects: Building Block Towards a Multi-core Python Runtime
01h 32mPyErlang -- a stepping stone towards behaviour-oriented concurrency in Python
01h 18mPython 103: Mmmm... Understanding Python's Memory Model, Mutability, and Methods
35mPEP 683: Immortal Objects - A new approach for memory managing
23mMemoirs of a Python Object: Memory Management and Improving Performance
01h 18mPython 103: Mmmm... Understanding Python's Memory Model, Mutability, and Methods
33mA low latency deepdive of Python with Cython
26mPython Performance at Scale - Making Python Faster at Instagram
