GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-145056: Add support for frozendict in dataclass asdict and astuple by eendebakpt · Pull Request #145125 · python/cpython

Conversation

@eendebakpt

@eendebakpt eendebakpt commented Feb 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adds support for frozendict in dataclassses.astype and dataclasses.asdict. The main effect is that astuple and asdict recurse into a frozendict (just like they recurse into a dict). For example

from typing import Any
from dataclasses import dataclass, astuple, asdict

@dataclass
class A:
    item : Any

asub = A(item=10)
a = A(item=frozendict({'sub': asub}))
print(astuple(a))

Output on main: (frozendict({'sub': A(item=10)}),)
Output on PR: (frozendict({'sub': (10,)}),)

Notes:

  • Tracking issue for PEP 814 is PEP 814: Add built-in frozendict type #141510
  • For exact dicts there is a fastpath (for performance reasons). In this PR we have not added a fastpath for the frozendict. If this turns out to be a common case, we can add the fastpath later.
  • Issue: Many pure python tools that have a special cases for dict should accept frozendict as well. #145056

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
eendebakpt added 2 commits February 22, 2026 11:57
@eendebakpt
Add support for frozendict in dataclass asdict and astuple
d2d5e95
@eendebakpt
update documentation
cc5d549
@eendebakpt
eendebakpt requested a review from ericvsmith as a code owner February 22, 2026 19:12
@bedevere-app bedevere-app Bot mentioned this pull request Feb 22, 2026
Many pure python tools that have a special cases for dict should accept frozendict as well. #145056
Open
@bedevere-app bedevere-app Bot added the awaiting review label Feb 22, 2026
blurb-it Bot and others added 4 commits February 22, 2026 19:36
@blurb-it
📜🤖 Added by blurb_it.
335cac5
@eendebakpt
fix news entry
f19c46d
@eendebakpt
Merge branch 'main' into dataclasses_frozendict_tests
d61d4f5
@eendebakpt
fix whatsnew entry
719c0f3
caje731
caje731 reviewed Feb 23, 2026
View reviewed changes
Comment thread Lib/dataclasses.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

eendebakpt added 2 commits February 23, 2026 12:56
@eendebakpt
review comments
97cec2d
@eendebakpt
Merge branch 'main' into dataclasses_frozendict_tests
bc112a2
@eendebakpt
eendebakpt requested a review from caje731 March 2, 2026 13:19
@eendebakpt
Merge branch 'main' into dataclasses_frozendict_tests
2fc6f65
JelleZijlstra
JelleZijlstra approved these changes Apr 23, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Apr 23, 2026
@JelleZijlstra
JelleZijlstra merged commit 8e43f3d into python:main Apr 23, 2026
55 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Apr 23, 2026
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@eendebakpt @ljfp
pythongh-145056: Add support for frozendict in dataclass asdict and a…
0046d00
…stuple (python#145125)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@ericvsmith ericvsmith Awaiting requested review from ericvsmith ericvsmith is a code owner
@caje731 caje731 Awaiting requested review from caje731

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@eendebakpt @JelleZijlstra @caje731
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.