Skip to content

[WIP] gh-141510: PEP 814: Add built-in frozendict type#141508

Draft
vstinner wants to merge 25 commits intopython:mainfrom
vstinner:frozendict
Draft

[WIP] gh-141510: PEP 814: Add built-in frozendict type#141508
vstinner wants to merge 25 commits intopython:mainfrom
vstinner:frozendict

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Nov 13, 2025

  • Basic tests
  • Bare minimum documentation
  • Support frozendict in marshal, pickle, json, copy
  • Replace dict with frozendict in many stdlib modules

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

* Basic tests
* Bare minimum documentation
* Support frozendict in marshal, pickle, json
* Replace dict with frozendict in many stdlib modules

Co-Authored-by: Donghee Na <donghee.na@python.org>
Co-Authored-by: Marco Sulla <github@marco.sulla.e4ward.com>
@vstinner vstinner changed the title [WIP] PEP 814: Add built-in frozendict type [WIP] gh-141510: PEP 814: Add built-in frozendict type Nov 13, 2025
@vstinner
Copy link
Member Author

This PR was created mainly to play with PEP 814 implementation, not to be merged.

If PEP 814 is accepted, this PR should be splitted into smaller parts, easier to review.

@vstinner
Copy link
Member Author

mypy / Run mypy on Lib/_pyrepl (pull_request)
mypy / Run mypy on Lib/tomllib (pull_request)

mypy fails with Name "frozendict" is not defined.

@vstinner
Copy link
Member Author

Tests / Android (x86_64) (pull_request) does crash, I'm not sure why.

  0:01:27 [ 39/497] test.test_concurrent_futures.test_interpreter_pool
  E/libsigchain: reverting to SIG_DFL handler for signal 11, ucontext 0x72d5b7547ac0

vstinner and others added 2 commits November 13, 2025 16:24
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
@vstinner
Copy link
Member Author

Tests / Android (x86_64) (pull_request) does crash, I'm not sure why.

It should be fixed by Add PyFrozenDict_Type to static_types commit.

vstinner and others added 2 commits November 14, 2025 23:20
Co-authored-by: kalvdans <github@kalvdans.no-ip.org>
@vstinner
Copy link
Member Author

vstinner commented Dec 1, 2025

TODO: Provide better error on hashing a mutable value:

>>> fd = frozendict(x=[1])
>>> hash(fd)
...
TypeError: cannot use 'tuple' as a set element (unhashable type: 'list')

@vstinner
Copy link
Member Author

This PR is a draft combining all changes to adopt frozendict in the stdlib. It's too big to be merged. I started to split this PR into smaller PRs with #144757 as a starting point: most basic PR just to add the frozendict type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants