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-74929: Make containment checks more efficient inFrameLocalsProxy#118624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ncoghlan merged 1 commit intopython:mainfromgaogaotiantian:frameproxy-contain
May 6, 2024

Conversation

gaogaotiantian
Copy link
Member

@gaogaotiantiangaogaotiantian commentedMay 6, 2024
edited by bedevere-appbot
Loading

Currently the more efficient contains function is not used when someone doeskey in frame.f_locals because that defaults tosq_contains and it's not properly hooked. The function is only called when usingframe.f_locals.__contains__(key).

This hookssq_contains so thein operation is much more efficient.

@gvanrossum
Copy link
Member

Is this a correctness issue or merely a performance issue?

@gaogaotiantian
Copy link
MemberAuthor

This is merely a performance issue. Without this change, theCONTAINS_OP will treat the proxy as a normal iterable and check the keys one by one. Theiter() method worked fine so the result is correct. A list of keys will be generated and iterated.

@ncoghlanncoghlan changed the titlegh-74929: Make contains work properly forFrameLocalsProxygh-74929: Make containment checks more efficient inFrameLocalsProxyMay 6, 2024
Copy link
Contributor

@ncoghlanncoghlan left a comment
edited
Loading

Choose a reason for hiding this comment

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

LGTM! (PR title tweaked to better reflect its purpose)

gvanrossum reacted with thumbs up emoji
@ncoghlanncoghlan merged commitafbe5bf intopython:mainMay 6, 2024
@gaogaotiantiangaogaotiantian deleted the frameproxy-contain branchMay 6, 2024 17:28
SonicField pushed a commit to SonicField/cpython that referenced this pull requestMay 8, 2024
…sProxy` (python#118624)Properly implement the `sq_contains` slot for frame locals proxy containment checks.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ncoghlanncoghlanncoghlan approved these changes

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@gaogaotiantian@gvanrossum@ncoghlan

[8]ページ先頭

©2009-2025 Movatter.jp