if func_arg.type == node.type:
return func_arg
elif node.type.assignable_from(func_arg.type) or func_arg.type.is_float:
- return ExprNodes.CastNode(func_arg, node.type)
+ return ExprNodes.TypecastNode(
+ node.pos, operand=func_arg, type=node.type)
elif function.name == 'float':
if func_arg.type.is_float or node.type.is_float:
if func_arg.type == node.type:
return func_arg
elif node.type.assignable_from(func_arg.type) or func_arg.type.is_float:
- return ExprNodes.CastNode(func_arg, node.type)
+ return ExprNodes.TypecastNode(
+ node.pos, operand=func_arg, type=node.type)
return node
### dispatch to specific optimisers
if func_arg.type is PyrexTypes.c_double_type:
return func_arg
elif node.type.assignable_from(func_arg.type) or func_arg.type.is_numeric:
- return ExprNodes.CastNode(func_arg, node.type)
+ return ExprNodes.TypecastNode(
+ node.pos, operand=func_arg, type=node.type)
return ExprNodes.PythonCapiCallNode(
node.pos, "__Pyx_PyObject_AsDouble",
self.PyObject_AsDouble_func_type,
def f(x):
return x
-def float_len(x):
+def len_f(x):
"""
- >>> float_len([1,2,3])
+ >>> len_f([1,2,3])
+ 3
+ """
+ return len(f(x))
+
+def float_len_f(x):
+ """
+ >>> float_len_f([1,2,3])
+ 3.0
+ """
+ return float(len(f(x)))
+
+def cast_len_f(x):
+ """
+ >>> cast_len_f([1,2,3])
3.0
"""
- float(len(f(x)))
+ return <double>len(f(x))