# HG changeset patch # User Paul Boddie # Date 1486160655 -3600 # Node ID baf7acd90a11ffb80d9d9e37514bbffaac2473aa # Parent 3dc8eff805e4c6447b8bb199fbf955b0b251505f Obtain and reuse next methods instead of accessing them repeatedly on iterators. diff -r 3dc8eff805e4 -r baf7acd90a11 common.py --- a/common.py Thu Feb 02 23:42:08 2017 +0100 +++ b/common.py Fri Feb 03 23:24:15 2017 +0100 @@ -533,18 +533,19 @@ node = compiler.ast.Stmt([ - # = {n.list}.__iter__ + # = {n.list}.__iter__().next compiler.ast.Assign( [compiler.ast.AssName(self.get_iterator_name(), "OP_ASSIGN")], - compiler.ast.CallFunc( - compiler.ast.Getattr(n.list, "__iter__"), - [] - )), + compiler.ast.Getattr( + compiler.ast.CallFunc( + compiler.ast.Getattr(n.list, "__iter__"), + [] + ), "next")), # try: # while True: - # ... = .next() + # ... = () # ... # except StopIteration: # pass @@ -556,7 +557,7 @@ compiler.ast.Assign( [n.assign], compiler.ast.CallFunc( - compiler.ast.Getattr(compiler.ast.Name(self.get_iterator_name()), "next"), + compiler.ast.Name(self.get_iterator_name()), [] )), n.body]),