Commit b97b545e authored by Robert Bradshaw's avatar Robert Bradshaw

Fix calls for all cdef methods whose names coincide with optimized ones.

parent f75cad42
......@@ -2596,11 +2596,21 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
],
exception_value="-1")
def _dispatch_to_method_handler(self, attr_name, self_arg,
is_unbound_method, type_name,
node, function, arg_list, kwargs):
if hasattr(function, 'type') and function.type.is_cfunction:
# Don't "optimize" already bound C calls.
return node
return super(OptimizeBuiltinCalls, self)._dispatch_to_method_handler(
attr_name, self_arg, is_unbound_method, type_name,
node, function, arg_list, kwargs)
def _handle_simple_method_object_append(self, node, function, args, is_unbound_method):
"""Optimistic optimisation as X.append() is almost always
referring to a list.
"""
if function.type.is_cfunction or len(args) != 2 or node.result_is_used:
if len(args) != 2 or node.result_is_used:
return node
return ExprNodes.PythonCapiCallNode(
......
......@@ -7,6 +7,16 @@ class A:
print args
return None
cdef class B:
"""
>>> B().call_pop()
'B'
"""
cdef pop(self):
return "B"
def call_pop(self):
return self.pop()
@cython.test_assert_path_exists('//PythonCapiCallNode')
@cython.test_fail_if_path_exists('//SimpleCallNode/AttributeNode')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment