Skip throw()
when finalizing generators, if they do not include a try
statement.
#100977
Labels
performance
Performance or resource usage
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
try
s and tend to be short lived, so this would definitely help there.The text was updated successfully, but these errors were encountered: