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-141510: Use frozendict in the stdlib by vstinner · Pull Request #144909 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Feb 17, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member
  • Issue: PEP 814: Add built-in frozendict type #141510

Sorry, something went wrong.

Uh oh!

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

All reactions
@vstinner @corona10
pythongh-141510: Use frozendict in the stdlib
300cf8f
Co-authored-by: Donghee Na <[email protected]>
@vstinner
vstinner requested review from AlexWaygood, JelleZijlstra, ethanfurman, rhettinger and tomasr8 as code owners February 17, 2026 12:20
@vstinner vstinner added the skip news label Feb 17, 2026
@vstinner
vstinner requested review from gpshead and picnixz as code owners February 17, 2026 12:20
@bedevere-app bedevere-app Bot added the awaiting core review label Feb 17, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Feb 17, 2026
PEP 814: Add built-in frozendict type #141510
Closed
@vstinner

vstinner commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

This PR only changes private names, so it should not impact stdlib users.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

If this change is merged, I will propose a follow-up PR which modify public names.

All reactions

Sorry, something went wrong.

Uh oh!

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

AlexWaygood
AlexWaygood approved these changes Feb 17, 2026
View reviewed changes

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One optional suggestion in typing.py

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/typing.py Resolved

Uh oh!

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

@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 17, 2026
@vstinner
Convert typing._PROTO_ALLOWLIST values to tuple
a7af8a7
picnixz
picnixz approved these changes Feb 17, 2026
View reviewed changes

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for ssl and a suggestion for opcode

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/opcode.py Outdated
_cache_format = {
"LOAD_GLOBAL": {
_cache_format = frozendict(
LOAD_GLOBAL={

@picnixz picnixz Feb 17, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values of LOAD_GLOBAL can also be a frozendict (that is, we can have nested frozendicts).

Sorry, something went wrong.

Uh oh!

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

All reactions
corona10
corona10 reviewed Feb 17, 2026
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto: #144910 (review)

Sorry, something went wrong.

Uh oh!

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

All reactions
@corona10

corona10 commented Feb 17, 2026

Copy link
Copy Markdown
Member

The SC does not allow mechanically replacing all uses of dict. Please wait for reviews from the code owners of each module.

All reactions

Sorry, something went wrong.

Uh oh!

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

@JelleZijlstra

JelleZijlstra commented Feb 17, 2026

Copy link
Copy Markdown
Member

What's the benefit of changing this in e.g. typing.py? It might break some users who modify this dict. That's not a supported use case, but we shouldn't go out of our way to break users unless there's some benefit.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
opcode: use frozendict for _cache_format values
9de00e2
@vstinner

vstinner commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

@JelleZijlstra:

What's the benefit of changing this in e.g. typing.py? It might break some users who modify this dict. That's not a supported use case, but we shouldn't go out of our way to break users unless there's some benefit.

The purpose of this change is to prevent dictionary modifications, especially if the modification is done by mistake.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner mentioned this pull request Feb 17, 2026
gh-141510: Implement copy and deepcopy for frozendict #144905
Merged
vstinner added 2 commits February 18, 2026 21:03
@vstinner
Revert stringprep change (public variable)
467d0d6
@vstinner
Merge branch 'main' into frozendict_stdlib
70d6ded
@vstinner

vstinner commented Feb 21, 2026

Copy link
Copy Markdown
Member Author

@JelleZijlstra: Do you prefer that I revert the typing._PROTO_ALLOWLIST change?

All reactions

Sorry, something went wrong.

Uh oh!

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

@picnixz

picnixz commented Feb 21, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

While the variables in stringprep are public, note that the file is autogenerated:

# This file is generated by mkstringprep.py. DO NOT EDIT.

And the docs clearly state:

As a result, these tables are exposed as functions, not as data structures

So, I really think we should consider any direct use or mutation of those variables as really a bad idea and I don't think we should even consider code that messes with that as being legitimate.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Feb 21, 2026

Copy link
Copy Markdown
Member Author

While the variables in stringprep are public, note that the file is autogenerated

I revert the stringprep change to restrict this change to private variables. Changing private variables type should be less controversial than changing public variables type.

picnixz reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@vstinner
Revert typing changes
e55a31d
@vstinner

vstinner commented Mar 2, 2026

Copy link
Copy Markdown
Member Author

I reverted the typing.py changes. I plan to merge this PR at the end of the week, unless there is a strong reason to not make these changes.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Mar 5, 2026

Copy link
Copy Markdown
Member Author

If someone really want/need to modify one of the frozendict, it remains possible. Example: platform._ver_stages |= frozendict(final=60)

$ ./python
>>> import platform
>>> platform._ver_stages
frozendict({'dev': 10, 'alpha': 20, 'a': 20, 'beta': 30, ..., 'p': 200})

>>> platform._ver_stages['final']=60
...
TypeError: 'frozendict' object does not support item assignment

>>> platform._ver_stages |= frozendict(final=60)
>>> platform._ver_stages
frozendict({'dev': 10, 'alpha': 20, 'a': 20, 'beta': 30, ..., 'p': 200, 'final': 60})

The purpose of this change is more to catch dictionaries modified by accident.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner merged commit 349639c into python:main Mar 6, 2026
48 checks passed

Uh oh!

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

@vstinner
vstinner deleted the frozendict_stdlib branch March 6, 2026 09:25
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 6, 2026
@vstinner

vstinner commented Mar 6, 2026

Copy link
Copy Markdown
Member Author

I merged my PR, thanks for reviews. If someone comes up with an concrete use case to modify one of these private attributes, we can revert the affected attribute.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner mentioned this pull request Apr 7, 2026
gh-145478: Implement frozendict into functools.partial #145960
Closed
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@vstinner @corona10 @ljfp
pythongh-141510: Use frozendict in the stdlib (python#144909)
4da8f17
Co-authored-by: Donghee Na <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@corona10 corona10 corona10 left review comments
@picnixz picnixz picnixz approved these changes
@AlexWaygood AlexWaygood AlexWaygood approved these changes
@JelleZijlstra JelleZijlstra Awaiting requested review from JelleZijlstra
@ethanfurman ethanfurman Awaiting requested review from ethanfurman ethanfurman is a code owner
@tomasr8 tomasr8 Awaiting requested review from tomasr8 tomasr8 is a code owner
@rhettinger rhettinger Awaiting requested review from rhettinger rhettinger is a code owner
@gpshead gpshead Awaiting requested review from gpshead gpshead is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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.

5 participants

@vstinner @corona10 @JelleZijlstra @picnixz @AlexWaygood
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.