Skip to content

[DIFF] Immutability for NoGIL for 3.15a - #112

Open
xFrednet wants to merge 1 commit into
immutable-basefrom
immutable-nogil
Open

xFrednet wants to merge 1 commit into
immutable-basefrom
immutable-nogil

Conversation

@xFrednet

@xFrednet xFrednet commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

This is the entire diff to implement shallow and deep immutability for Python. This also includes the write-barriers from #63. The relevant files for this PR are probably:

Include/cpython/immutability.h
Include/internal/pycore_gc.h
Include/internal/pycore_immutability.h
Include/internal/pycore_object.h
Include/internal/pycore_stackref.h
Include/internal/pycore_weakref.h
Include/object.h
Include/refcount.h
Lib/immutable.py
Modules/_immutablemodule.c
Modules/_weakref.c
Objects/object.c
Objects/weakrefobject.c
Python/ceval.c
Python/crossinterp.c
Python/gc.c
Python/immutability.c

📚 Documentation preview 📚: https://cpython-previews--112.org.readthedocs.build/

@xFrednet

Copy link
Copy Markdown
Collaborator Author

The benchmark numbers after the rewrite for GIL-enabled are in:

image

It is slightly worse with a Geomean slowdown of 1.042. We can probably optimize it more, but for now, this should be good enough to rebase regions on it.

@xFrednet
xFrednet requested a review from mjp41 September 28, 2026 09:02
Co-authored-by: Matthew A Johnson <matjoh@microsoft.com>
Co-authored-by: Matthew Parkinson <mattpark@microsoft.com>
Co-authored-by: David Klement <kulisak12lp@gmail.com>
Co-authored-by: Tobias Wrigstad <tobias.wrigstad@it.uu.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant