Title: Teach `pprint` about `frozendict` · Issue #145070 · python/cpython · GitHub
Open Graph Title: Teach `pprint` about `frozendict` · Issue #145070 · python/cpython
X Title: Teach `pprint` about `frozendict` · Issue #145070 · python/cpython
Description: 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)...
Open Graph Description: 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 frozendic...
X Description: 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 f...
Opengraph URL: https://github.com/python/cpython/issues/145070
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Teach `pprint` about `frozendict`","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nThe `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`:\n```python\n\u003e\u003e\u003e f = frozendict.fromkeys(range(10))\n\u003e\u003e\u003e g = frozendict.fromkeys(range(10))\n\u003e\u003e\u003e h = {0: f, 1: frozendict({2: g})}\n\u003e\u003e\u003e pprint.pp(h)\n{0: frozendict({0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None}),\n 1: frozendict({2: frozendict({0: None, 1: None, 2: None, 3: None, 4: None, 5: None, 6: None, 7: None, 8: None, 9: None})})}\n```\n\nWe want `frozendict` to be pretty printed like this:\n```python\n\u003e\u003e\u003e f = frozendict.fromkeys(range(10))\n\u003e\u003e\u003e g = frozendict.fromkeys(range(10))\n\u003e\u003e\u003e h = {0: f, 1: frozendict({2: g})}\n\u003e\u003e\u003e pprint.pp(h)\n{0: frozendict({0: None,\n 1: None,\n 2: None,\n 3: None,\n 4: None,\n 5: None,\n 6: None,\n 7: None,\n 8: None,\n 9: None}),\n 1: frozendict({2: frozendict({0: None,\n 1: None,\n 2: None,\n 3: None,\n 4: None,\n 5: None,\n 6: None,\n 7: None,\n 8: None,\n 9: None})})}\n```\n\nLet me know whether you think the pretty printing should be different.\n\ncc: @rhettinger for validating that the pretty printing should be as above.\n\nI'll create a trivial PR to fix this once validated.\n\n\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_","author":{"url":"https://github.com/devdanzin","@type":"Person","name":"devdanzin"},"datePublished":"2026-02-21T11:05:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/145070/cpython/issues/145070"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a0a44a8f-5b0f-d2aa-ff3e-7a1d062578a8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBA6:18EF1B:A8F1DCF:EC028C6:6A50E844 |
| html-safe-nonce | b872d9a8a2fb914e51a13fc6087c842f26e83b57f3a80c3856102a54813e3fbf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkE2OjE4RUYxQjpBOEYxRENGOkVDMDI4QzY6NkE1MEU4NDQiLCJ2aXNpdG9yX2lkIjoiNDQ1NjEzNDYwNTUzNjI5MDg4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 27d0d5ba9883b735bf391d72a0598d1a448b121808412e935b0b5ffa6093b01b |
| hovercard-subject-tag | issue:3971848659 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/145070/issue_layout |
| twitter:image | https://opengraph.githubassets.com/99ecac46d6ec51ac289e2602b787d90a0ac91536c49ded1cb8ba7a44a0fcc4d5/python/cpython/issues/145070 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/99ecac46d6ec51ac289e2602b787d90a0ac91536c49ded1cb8ba7a44a0fcc4d5/python/cpython/issues/145070 |
| og:image:alt | 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 frozendic... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devdanzin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fb19d617b534959801b4b7453938ecf1dfa22131 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width