From: Stefan Behnel Date: Sun, 21 Mar 2010 19:50:08 +0000 (+0100) Subject: drop redundant C->Py->C coercions after optimisations X-Git-Tag: 0.13.beta0~263 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7a738fd026fd4cd08158f4bd4570130e590d8658;p=cython.git drop redundant C->Py->C coercions after optimisations --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 5d587160..85a405a8 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -962,6 +962,11 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): return arg else: return arg.coerce_to(node.type, self.env_stack[-1]) + if isinstance(arg, ExprNodes.CoerceToPyTypeNode): + if arg.type is PyrexTypes.py_object_type: + if node.type.assignable_from(arg.arg.type): + # completely redundant C->Py->C coercion + return arg.arg.coerce_to(node.type, self.env_stack[-1]) if not isinstance(arg, ExprNodes.SimpleCallNode): return node if not (node.type.is_int or node.type.is_float):