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 — Teach `pprint` about `frozendict` · Issue #145070 · python/cpython

Teach pprint about frozendict #145070

New issue
Copy link
New issue
Copy link
Closed
Closed
Teach pprint about frozendict#145070
Copy link
Assignees
devdanzin
Labels
easystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@devdanzin
devdanzin
opened on Feb 21, 2026
Issue body actions

Feature or enhancement

Proposal:

The pprint code has a number of type or protocol specific handlers but doesn't have one for frozendict yet. So, we don't currently get pretty printing for frozendict:

>>> f = frozendict.fromkeys(range(10))
>>> g = frozendict.fromkeys(range(10))
>>> h = {0: f, 1: frozendict({2: g})}
>>> pprint.pp(h)
{0: frozendict({0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None}),
 1: frozendict({2: frozendict({0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None})})}

We want frozendict to be pretty printed like this:

>>> f = frozendict.fromkeys(range(10))
>>> g = frozendict.fromkeys(range(10))
>>> h = {0: f, 1: frozendict({2: g})}
>>> pprint.pp(h)
{0: frozendict({0: None,
                1: None,
                2: None,
                3: None,
                4: None,
                5: None,
                6: None,
                7: None,
                8: None,
                9: None}),
 1: frozendict({2: frozendict({0: None,
                               1: None,
                               2: None,
                               3: None,
                               4: None,
                               5: None,
                               6: None,
                               7: None,
                               8: None,
                               9: None})})}

Let me know whether you think the pretty printing should be different.

cc: @rhettinger for validating that the pretty printing should be as above.

I'll create a trivial PR to fix this once validated.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Activity

  1. devdanzin
    self-assigned this
    on Feb 21, 2026
  2. devdanzin
    added a parent issue on Feb 21, 2026
    • Many pure python tools that have a special cases for dict should accept frozendict as well. #145056
  3. devdanzin
    added
    type-featureA feature request or enhancementA feature request or enhancement
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    easy
    on Feb 21, 2026
  4. devdanzin commented on Feb 21, 2026

    @devdanzin
    devdanzin
    on Feb 21, 2026
    MemberAuthor
    More actions

    Being addressed in #144908, which technically makes this a duplicate of #141510.

    I think it's worth keeping it open as it has a tighter scope than that issue, please close if you disagree.

  5. vstinner commented on Feb 21, 2026

    @vstinner
    vstinner
    on Feb 21, 2026
    Member
    More actions

    Feature implementated in the change commit 770d354. I close the issue.

  6. vstinner
    closed this as completedon Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @devdanzin
    devdanzin

Labels

easystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — 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.