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-100762: Don't callgen.throw() ingen.close(), unless necessary.#101013

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
markshannon merged 7 commits intopython:mainfromfaster-cpython:faster-gen-close
Jan 24, 2023

Conversation

@markshannon
Copy link
Member

@markshannonmarkshannon commentedJan 13, 2023
edited by bedevere-bot
Loading

Changeoparg ofYIELD_VALUE to hold the exception handler depth.
We can then test that ingen.close() to avoid callinggen.throw() unless necessary.

@markshannon
Copy link
MemberAuthor

markshannon commentedJan 13, 2023
edited
Loading

Using the benchmarks in#101011 (comment), but usingtimeit instead ofpyperf and a non-pgo and no-lto build because I'm impatient.
I get no significant change on "comprehension", "generator exhaust", and "all", but runtime is about 60% for "generator" and "all with comparison"

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

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

I guess this will not be easy to backport, as we won't want to change the meaning of oparg in 3.11? Then again it appears to be unused except for the assert. Maybe it should just be a bit indicating whether it's safe to optimize out the throw?

@brandtbucher
Copy link
Member

I guess this will not be easy to backport, as we won't want to change the meaning of oparg in 3.11?

I think a similar change in 3.11 would actually be simpler: just check if an exception table exists. If not, don't throw.

The only reason we need theYIELD_VALUE oparg in this 3.12 patch is because every generator now has an implicittry/except around the entire body, so it's a bit trickier to figure out if we're in that handler (which we can safely ignore) or something else.

@gvanrossum
Copy link
Member

Great, it'll just bedifferent. :-)

brandtbucher reacted with thumbs up emoji

@markshannonmarkshannon added the needs backport to 3.11only security fixes labelJan 24, 2023
@markshannonmarkshannon merged commitf02fa64 intopython:mainJan 24, 2023
@miss-islington
Copy link
Contributor

Thanks@markshannon for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry,@markshannon, I could not cleanly backport this to3.11 due to a conflict.
Please backport usingcherry_picker on command line.
cherry_picker f02fa64bf2d03ef7a28650c164e17a5fb5d8543d 3.11

@brandtbucher
Copy link
Member

I don’t think this should be backported as-is, right? (See my comment above.)

@markshannon
Copy link
MemberAuthor

markshannon commentedJan 25, 2023
edited
Loading

@brandtbucher agreed.
The changes to genobject.c need backporting (with the change you suggest for determining when to skip the call togen.throw(), but the other changes are 3.12 specific.

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

Reviewers

@gvanrossumgvanrossumgvanrossum left review comments

@brandtbucherbrandtbucherbrandtbucher approved these changes

@iritkatrieliritkatrielAwaiting requested review from iritkatrieliritkatriel is a code owner

Assignees

@markshannonmarkshannon

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@markshannon@brandtbucher@gvanrossum@miss-islington@iritkatriel@bedevere-bot@ZeroIntensity

[8]ページ先頭

©2009-2025 Movatter.jp