From: Stefan Behnel Date: Fri, 28 Nov 2008 09:11:54 +0000 (+0100) Subject: fix final optimisations for calls inside of assignments X-Git-Tag: 0.11-beta~192 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=83781ad5acc27477905d9c9d421cbc5a91f2bae8;p=cython.git fix final optimisations for calls inside of assignments --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index c587bbd5..c47a1989 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -350,6 +350,10 @@ class FinalOptimizePhase(Visitor.CythonTransform): - isinstance -> typecheck for cdef types """ def visit_SingleAssignmentNode(self, node): + """Avoid redundant initialisation of local variables before their + first assignment. + """ + self.visitchildren(node) if node.first: lhs = node.lhs lhs.lhs_of_first_assignment = True @@ -360,6 +364,9 @@ class FinalOptimizePhase(Visitor.CythonTransform): return node def visit_SimpleCallNode(self, node): + """Replace generic calls to isinstance(x, type) by a more efficient + type check. + """ self.visitchildren(node) if node.function.type.is_cfunction and isinstance(node.function, ExprNodes.NameNode): if node.function.name == 'isinstance':