Skip to content

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

Closed
vstinner wants to merge 25 commits into
python:mainfrom
vstinner:frozendict
Closed

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

Conversation

@vstinner

@vstinnervstinner commented Nov 13, 2025

Copy link
Copy Markdown
Member
  • 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>
@vstinnervstinner changed the title [WIP] PEP 814: Add built-in frozendict type[WIP] gh-141510: PEP 814: Add built-in frozendict typeNov 13, 2025
@vstinner

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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

Comment threadDoc/library/stdtypes.rst Outdated
vstinnerand others added 2 commits November 13, 2025 16:24
Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
@vstinner

Copy link
Copy Markdown
MemberAuthor

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.

Comment threadObjects/dictobject.c
Comment threadLib/copy.py Outdated
Comment threadLib/json/tool.py Outdated
Comment threadModules/_json.c Outdated
Comment threadModules/_pickle.c
Comment threadObjects/dictobject.c
Comment threadObjects/dictobject.c Outdated
Comment threadLib/pydoc_data/topics.py Outdated
vstinnerand others added 2 commits November 14, 2025 23:20
Co-authored-by: kalvdans <github@kalvdans.no-ip.org>
@vstinner

Copy link
Copy Markdown
MemberAuthor

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')

Comment threadObjects/dictobject.c
@vstinner

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
Member

@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
Copy Markdown
Contributor

Thanks!

@vstinner

Copy link
Copy Markdown
MemberAuthor

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 deleted the frozendict branch February 17, 2026 22:17
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@vstinner@benediktjohannes@hugovk@sergey-miryanov@eendebakpt@kalvdans@Zaczero@nineteendo@nazeerali4325-commits