Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jan 13, 2023

Change oparg of YIELD_VALUE to hold the exception handler depth.
We can then test that in gen.close() to avoid calling gen.throw() unless necessary.

@markshannon
Copy link
Member Author

markshannon commented Jan 13, 2023

Using the benchmarks in #101011 (comment), but using timeit instead of pyperf 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"


# Python 3.12a1 3517 (Change YIELD_VALUE oparg to exception block depth)
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing you have a 3516 PR open somewhere?

.. versionchanged:: 3.11
oparg set to be the stack depth, for efficient handling on frames.
.. versionchanged:: 3.12
oparg set to be the exception block depth, for efficient closing of generators.
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the 3.11 note be retained (assuming it's truthful)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants