# HG changeset patch # User Paul Boddie # Date 1529858823 -7200 # Node ID ed201ad4d8e1cf534ccb45e959fff38da99b7f07 # Parent cab08f354ecb8b2501074a90da3a8c4724d8c274 Moved next method retrieval outside "for" loop bodies. Due to alias-related improvements, the temporary name providing access to the method should yield reference information and cause the method to be efficiently invoked. diff -r cab08f354ecb -r ed201ad4d8e1 common.py --- a/common.py Sun Jun 24 18:43:57 2018 +0200 +++ b/common.py Sun Jun 24 18:47:03 2018 +0200 @@ -552,6 +552,8 @@ self.next_temporary() t1 = self.get_temporary_name() self.next_temporary() + t2 = self.get_temporary_name() + self.next_temporary() node = compiler.ast.Stmt([ @@ -568,13 +570,18 @@ compiler.ast.Getattr(compiler.ast.Name(t0), "__iter__"), [])), + # = .next # try: # while True: - # ... = .next() + # ... = () # ... # except StopIteration: # pass + compiler.ast.Assign( + [compiler.ast.AssName(t2, "OP_ASSIGN")], + compiler.ast.Getattr(compiler.ast.Name(t1), "next")), + compiler.ast.TryExcept( compiler.ast.While( compiler.ast.Name("True"), @@ -582,7 +589,7 @@ compiler.ast.Assign( [n.assign], compiler.ast.CallFunc( - compiler.ast.Getattr(compiler.ast.Name(t1), "next"), + compiler.ast.Name(t2), [] )), n.body]),