-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-100762: Don't call gen.throw()
in gen.close()
, unless necessary.
#101013
Conversation
…xpensive gen.throw() in gen.close() where possible.
Using the benchmarks in #101011 (comment), but using |
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.
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?
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 the |
Great, it'll just be different. :-) |
Thanks @markshannon for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, @markshannon, I could not cleanly backport this to |
I don’t think this should be backported as-is, right? (See my comment above.) |
@brandtbucher agreed. |
Change
oparg
ofYIELD_VALUE
to hold the exception handler depth.We can then test that in
gen.close()
to avoid callinggen.throw()
unless necessary.