Skip to content

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

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

[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.

@benediktjohannes
Copy link
Contributor

@vstinner is it purposed that this draft PR is linked in the documentation at „reference implementation“ in PEP 814? I know that this includes more than the other PR, but I think that it was probably better to link the real PRs with the real changes made because they include really every single change correctly rather than a draft, no?

@hugovk
Copy link
Member

hugovk commented Feb 17, 2026

@benediktjohannes PEPs are historical documents (PEP 814 will soon have a banner to this effect), so it's fine for https://peps.python.org/pep-0814/#reference-implementation to point to this PR. It was the reference implementation at the time the PEP was written, discussed and accepted.

The real implementation is another matter, and is being committed in smaller PRs. We can follow along via the issue, #141510.

@benediktjohannes
Copy link
Contributor

Thanks!

@vstinner
Copy link
Member Author

I started to split this PR into smaller PRs with #144757 as a starting point: most basic PR just to add the frozendict type.

I created many PRs in #141510. This PR is no longer needed, I close it.

@vstinner vstinner closed this Feb 17, 2026
@vstinner vstinner deleted the frozendict branch February 17, 2026 22:17
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.

8 participants