Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-141510: Optimize frozendict(frozendict)#145592

Open
vstinner wants to merge 4 commits intopython:mainfrom
vstinner:frozendict_new_same
Open

gh-141510: Optimize frozendict(frozendict)#145592
vstinner wants to merge 4 commits intopython:mainfrom
vstinner:frozendict_new_same

Conversation

@vstinner
Copy link
Member

@vstinnervstinner commentedMar 6, 2026
edited by bedevere-appbot
Loading

Return the same object unmodified if it's exactly the frozendict type.

jorenham reacted with thumbs up emoji
Return the same object unmodified if it's exactly the frozendicttype.
@vstinner
Copy link
MemberAuthor

cc@encukou

Comment on lines +8206 to +8209
if (PyFrozenDict_CheckExact(iterable)) {
// PyFrozenDict_New(frozendict) returns the same object unmodified
returnPy_NewRef(iterable);
}
Copy link
Member

Choose a reason for hiding this comment

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

This is how I'd like it, but do note thatPyTuple_New orPyFrozenSet_New will always return a new object.

It's probably worth noting this in documentation.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Hmm, usually we don't document such optimization, but ok, I added it toPyFrozenDict_New() documentation as a "CPython implementation detail".

Copy link
Contributor

Choose a reason for hiding this comment

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

Why document it if it is an internal implementation detail anyways? It gives the wrong sense that users can rely on this in CPython

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@encukouencukouencukou left review comments

@kumaraditya303kumaraditya303kumaraditya303 left review comments

@methanemethaneAwaiting requested review from methanemethane is a code owner

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

@ZeroIntensityZeroIntensityAwaiting requested review from ZeroIntensityZeroIntensity is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@vstinner@encukou@kumaraditya303

[8]ページ先頭

©2009-2026 Movatter.jp