From ad10cfea5feac176a2cb972c2c563abcaf53b388 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 19 Dec 2008 14:50:39 +0100 Subject: [PATCH] removed original iter-range optimisation (now replaced by a transform) --- Cython/Compiler/Nodes.py | 50 +--------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 86e5b529..633e1aae 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -3687,58 +3687,10 @@ class ForInStatNode(LoopNode, StatNode): self.body.analyse_declarations(env) if self.else_clause: self.else_clause.analyse_declarations(env) - - def analyse_range_step(self, args): - import ExprNodes - # The direction must be determined at compile time to set relations. - # Otherwise, return False. - if len(args) < 3: - self.step = ExprNodes.IntNode(pos = args[0].pos, value='1') - self.relation1 = '<=' - self.relation2 = '<' - return True - else: - step = args[2] - if isinstance(step, ExprNodes.UnaryMinusNode) and isinstance(step.operand, ExprNodes.IntNode): - step = ExprNodes.IntNode(pos = step.pos, value=str(-int(step.operand.value, 0))) - if isinstance(step, ExprNodes.IntNode): - step_value = int(step.value, 0) - if step_value > 0: - self.step = step - self.relation1 = '<=' - self.relation2 = '<' - return True - elif step_value < 0: - self.step = ExprNodes.IntNode(pos = step.pos, value=str(-step_value)) - self.relation1 = '>=' - self.relation2 = '>' - return True - return False - - + def analyse_expressions(self, env): import ExprNodes self.target.analyse_target_types(env) - if False: # Options.convert_range and self.target.type.is_int: - sequence = self.iterator.sequence - if isinstance(sequence, ExprNodes.SimpleCallNode) \ - and sequence.self is None \ - and isinstance(sequence.function, ExprNodes.NameNode) \ - and (sequence.function.name == 'range' or sequence.function.name == 'xrange'): - args = sequence.args - # Make sure we can determine direction from step - if self.analyse_range_step(args): - # Mutate to ForFrom loop type - self.__class__ = ForFromStatNode - if len(args) == 1: - self.bound1 = ExprNodes.IntNode(pos = sequence.pos, value='0') - self.bound2 = args[0] - else: - self.bound1 = args[0] - self.bound2 = args[1] - ForFromStatNode.analyse_expressions(self, env) - return - self.iterator.analyse_expressions(env) self.item = ExprNodes.NextNode(self.iterator, env) self.item = self.item.coerce_to(self.target.type, env) -- 2.26.2