Skip to content

Skip throw() when finalizing generators, if they do not include a try statement. #100977

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

Closed
markshannon opened this issue Jan 12, 2023 · 2 comments
Labels
performance Performance or resource usage

Comments

@markshannon
Copy link
Member

It would be easy enough to tag code objects that do not have explicit try statements.
We could skip the throw step when closing generators for such code objects.

Before "zero cost" exceptions, we checked the the block stack. If it was empty we would skip the throw step.
We could be something similar by checking the exception table, but the introduction of a generator wide implicit try-except to handle https://peps.python.org/pep-0479/ complicates this.

See #100762 for the genesis of this.
Generator expressions never have trys and tend to be short lived, so this would definitely help there.

@markshannon markshannon added the performance Performance or resource usage label Jan 12, 2023
@markshannon
Copy link
Member Author

@brandtbucher FYI

@markshannon
Copy link
Member Author

The main discussion seems to be happening on #100762, so I'm closing this.

@markshannon markshannon closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage
Projects
None yet
Development

No branches or pull requests

1 participant