From 7a738fd026fd4cd08158f4bd4570130e590d8658 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 21 Mar 2010 20:50:08 +0100 Subject: [PATCH] drop redundant C->Py->C coercions after optimisations --- Cython/Compiler/Optimize.py | 5 +++++ 1 file changed, 5 insertions(+) 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): -- 2.26.2