Author: Ronan Lamy <[email protected]>
Branch: less-stringly-ops
Changeset: r66246:67521a7fb22d
Date: 2013-08-12 16:23 +0100
http://bitbucket.org/pypy/pypy/changeset/67521a7fb22d/
Log: Do not create so many useless implicit exception blocks
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -456,7 +456,7 @@
self.guessexception(op.canraise)
return op.result
- def guessexception(self, exceptions):
+ def guessexception(self, exceptions, force=False):
"""
Catch possible exceptions implicitly.
@@ -465,6 +465,11 @@
even if the interpreter re-raises the exception, it will not be the
same ImplicitOperationError instance internally.
"""
+ if not force and not any(isinstance(block, (ExceptBlock, FinallyBlock))
+ for block in self.blockstack):
+ # The implicit exception wouldn't be caught and would later get
+ # removed, so don't bother creating it.
+ return
self.recorder.guessexception(self, *exceptions)
def build_flow(self):
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -228,7 +228,7 @@
frame.replace_in_stack(it, next_unroller)
return const(v)
w_item = frame.do_operation("next", w_iter)
- frame.guessexception([StopIteration, RuntimeError])
+ frame.guessexception([StopIteration, RuntimeError], force=True)
return w_item
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit