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: Update specializer to support frozendict with BINARY_SUBSCR by corona10 · Pull Request #144911 · python/cpython

Conversation

@corona10

@corona10 corona10 commented Feb 17, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

We need to register frozendict for support in the specializer.

Since frozendict is only introduced in Python 3.15, it is not yet widely used. However, it is thread safe for many operations, including CALL_LEN and BINARY_OP_SUBSCR. It could also be optimized more aggressively in the JIT using KNOWN_CLASS optimizations in the pipeline.

This is just part of a draft PR. I am also happy to make _BINARY_OP_SUBSCR_FROZEN_DICT part of _BINARY_OP_SUBSCR_DICT, depending on what the JIT team prefers.

Without this PR, frozendict would be at a performance disadvantage, even though it is intended to be a first-class citizen alongside dict.

  • 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.

Fidget-Spinner reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
corona10 added 2 commits February 17, 2026 21:45
@corona10
pythongh-141510: Update specialzier to support frozendict with BINARY…
a9e4c02
…_SUBSCR
@corona10
Add NEWS.d
9cb3cd7
@corona10
corona10 requested review from markshannon and methane as code owners February 17, 2026 12:51
@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
@corona10
corona10 requested review from Fidget-Spinner and vstinner February 17, 2026 12:51
@corona10 corona10 changed the title gh-141510: Update specialzier to support frozendict with BINARY_SUBSCR gh-141510: Update specializer to support frozendict with BINARY_SUBSCR Feb 17, 2026
corona10 added 2 commits February 17, 2026 22:00
@corona10
fix
1549414
@corona10
fix
d22f149
@Sacul0457

Sacul0457 commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Would it be good if _GUARD_NOS_FROZEN_DICT was added to optimizer_bytecodes.c so that it could be removed by the optimizer if the type is known?

All reactions

Sorry, something went wrong.

Uh oh!

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

@Fidget-Spinner

Fidget-Spinner commented Feb 17, 2026

Copy link
Copy Markdown
Member

I think it's better to focus on getting the specializer correct in this PR for now. We can leave the JIT for another PR.

corona10 and Sacul0457 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

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

@corona10

corona10 commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

@Sacul0457 I think that we have to, I will update the PR or handle it at the seperate PR, but it needs feedback from JIT team first :)

Sacul0457 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
vstinner reviewed Feb 17, 2026
View reviewed changes
Comment thread Objects/dictobject.c Resolved

Uh oh!

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

Comment thread Include/internal/pycore_dict.h Resolved

Uh oh!

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

corona10 added 2 commits February 17, 2026 22:38
@corona10
fix for free-threading
b4a06fd
@corona10
fix symbol issue
c29933d
@Fidget-Spinner

Fidget-Spinner commented Feb 17, 2026

Copy link
Copy Markdown
Member

This needs tests in test_opcache for the specialization success and failure case.

All reactions

Sorry, something went wrong.

Uh oh!

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

corona10 added 2 commits February 17, 2026 23:34
@corona10
Address code review
9f1c969
@corona10
Increase _Py_MAX_MANAGED_STATIC_BUILTIN_TYPES for frozendict
acfab36
@corona10

corona10 commented Feb 17, 2026

Copy link
Copy Markdown
Member Author

Once the PR is merged, I am also going to work on CONTAINS_OP_FROZENDICT too.

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10
corona10 requested a review from vstinner February 17, 2026 14:53
vstinner
vstinner reviewed Feb 17, 2026
View reviewed changes
Comment thread Include/internal/pycore_dict.h Resolved

Uh oh!

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

Comment thread Include/internal/pycore_dict.h Resolved

Uh oh!

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

@corona10 @vstinner
Update Include/internal/pycore_dict.h
4c7b59a
Co-authored-by: Victor Stinner <[email protected]>
@corona10
corona10 requested a review from vstinner February 17, 2026 15:31
@corona10

corona10 commented Feb 17, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member Author

@Fidget-Spinner Now whole unit tests are passed.

All reactions

Sorry, something went wrong.

Uh oh!

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

corona10 added 3 commits February 18, 2026 00:40
@corona10
Rename to BINARY_OP_SUBSCR_FROZENDICT
805fe2e
@corona10
Merge remote-tracking branch 'origin/pythongh-141510-specializer' into …
a608252
…pythongh-141510-specializer
@corona10
Address code review
dd616b4
vstinner
vstinner reviewed Feb 17, 2026
View reviewed changes
Comment thread Objects/dictobject.c Resolved

Uh oh!

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

Comment thread Python/bytecodes.c Resolved

Uh oh!

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

Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-02-17-21-46-55.gh-issue-141510.8SqYuG.rst Resolved

Uh oh!

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

@corona10
Address code review
8311052
@corona10
corona10 requested a review from vstinner February 17, 2026 21:28
vstinner
vstinner approved these changes Feb 17, 2026
View reviewed changes

@vstinner vstinner 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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Feb 17, 2026
@markshannon

markshannon commented Feb 18, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Do you have any evidence that this will improve performance?

Opcodes are a limited resource, and since no one is using frozen dicts yet, this is just going to slow down the interpreter by adding bulk.

Relaxing the guard in BINARY_OP_SUBSCR_DICT to check for any dict, and removing the redundant check in PyDict_GetItemRef would achieve your goal without lots of extra code or any slow down.

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10

corona10 commented Feb 18, 2026

Copy link
Copy Markdown
Member Author

Relaxing the guard in BINARY_OP_SUBSCR_DICT to check for any dict, and removing the redundant check in PyDict_GetItemRef would achieve your goal without lots of extra code or any slow down.

I like that option too.

All reactions

Sorry, something went wrong.

Uh oh!

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

@corona10 corona10 mentioned this pull request Feb 18, 2026
gh-141510: Update specializer to support frozendict #144949
Merged
@vstinner

vstinner commented Feb 18, 2026

Copy link
Copy Markdown
Member

@corona10 wrote #144949 to modify existing CONTAINS_OP_DICT and BINARY_OP_SUBSCR_DICT opcodes for frozendict. I close this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner vstinner closed this Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@methane methane Awaiting requested review from methane methane is a code owner
@Fidget-Spinner Fidget-Spinner Awaiting requested review from Fidget-Spinner

Uh oh!

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

Assignees

No one assigned

Labels

awaiting merge

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

@corona10 @Sacul0457 @Fidget-Spinner @markshannon @vstinner
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 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.