Skip to content

PEP 814: Add built-in frozendict type #141510

Closed
3 of 4 issues completed
Closed

Description

@vstinner

Feature or enhancement

Proposal:

Issue created to track the implementation of https://peps.python.org/pep-0814/.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added a commit that references this issue on Mar 16, 2026
  2. luckydonald commented on Mar 18, 2026

    @luckydonald

    Short question - I appologize if this is the wrong place for this, please kindly point me where it would be better.

    Do I now have to write instead of isinstance(somevar, dict) now?
    So do I write isinstance(somevar, (dict, frozendict)) both every time I want something to support reading json-like data?

    Is there a shared base I can easily check?
    Or is dict now a subtype of frozendict, so checking that is enough, still? (After all it reads like dict now is like frozendict, just with update methods)

  3. vstinner commented on Mar 18, 2026

    @vstinner
    MemberAuthor

    isinstance(somevar, (dict, frozendict)) is the correct check, yes. The common case class between dict and frozendict is object which is not helpful here.

  4. luckydonald commented on Mar 18, 2026

    @luckydonald

    Thanks a lot for your answer.

    This feels like quite the change for every library on pypi which currently supports reading from dicts (e.g. config) needing to be updated to support both?

    There is no similar approach as Iterable for tuple, list, isn't there?
    Like

    from collections.abc import Iterable
    
    if isinstance(e, Iterable):
        # e is iterable

    or similar?

    From what I read TypedDict would also not be compatible, and creating an alternative is not part of this python release?

  5. entwanne commented on Mar 18, 2026

    @entwanne

    There is the Mapping abstract class in collections.abc if you want to recognize both (and also other mapping types such as mappingproxy).

  6. added a commit that references this issue on Mar 18, 2026
  7. vstinner commented on Mar 18, 2026

    @vstinner
    MemberAuthor

    The isinstance(arg, dict) question has been asked multiple times, so I wrote PR gh-146107 to write solutions in the documentation.

  8. added a commit that references this issue on Mar 18, 2026
  9. vstinner commented on Mar 21, 2026

    @vstinner
    MemberAuthor

    I close the issue again, even if they are still two open pull requests. The main feature (adding frozendict type) is done. Thanks everyone who has been involved in this heavy work!

  10. added a commit that references this issue on Mar 31, 2026
  11. added a commit that references this issue on Apr 16, 2026
  12. added 20 commits that reference this issue on Apr 25, 2026
  13. added 20 commits that reference this issue on Apr 25, 2026
  14. added 6 commits that reference this issue on Apr 25, 2026
  15. da-woods commented on Jun 16, 2026

    @da-woods
    Contributor

    I attached a couple of PRs to this (which maybe I should have created new issues for in hindsight...). The more important of them is probably #150799 (which documents and tests their _Py_TPFLAGS_MATCH_SELF behaviour

  16. added 4 commits that reference this issue on Jun 18, 2026
  17. added 2 commits that reference this issue on Jul 5, 2026
  18. added 2 commits that reference this issue on Jul 14, 2026
  19. added a commit that references this issue on Aug 17, 2026
  20. added a commit that references this issue on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions