Commit 8f1599cd authored by Stefan Behnel's avatar Stefan Behnel

exclude non-builtin C methods from builtins optimisation again

parent 083b8d94
...@@ -2596,16 +2596,6 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin, ...@@ -2596,16 +2596,6 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
], ],
exception_value="-1") 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): def _handle_simple_method_object_append(self, node, function, args, is_unbound_method):
"""Optimistic optimisation as X.append() is almost always """Optimistic optimisation as X.append() is almost always
referring to a list. referring to a list.
......
...@@ -598,7 +598,11 @@ class MethodDispatcherTransform(EnvTransform): ...@@ -598,7 +598,11 @@ class MethodDispatcherTransform(EnvTransform):
attr_name = function.attribute attr_name = function.attribute
if function.type.is_pyobject: if function.type.is_pyobject:
self_arg = function.obj self_arg = function.obj
elif node.self: elif node.self and function.entry:
entry = function.entry.as_variable
if not entry or not entry.is_builtin:
return node
# C implementation of a Python builtin method - see if we find further matches
self_arg = node.self self_arg = node.self
arg_list = arg_list[1:] # drop CloneNode of self argument arg_list = arg_list[1:] # drop CloneNode of self argument
else: else:
......
...@@ -52,6 +52,19 @@ def test_append(L): ...@@ -52,6 +52,19 @@ def test_append(L):
return L return L
def test_append_typed(list L not None):
"""
>>> test_append_typed([])
None
None
[1, 2, (3, 4)]
"""
print L.append(1)
L.append(2)
print L.append((3,4))
return L
def append_unused_retval(L): def append_unused_retval(L):
""" """
>>> append_unused_retval([]) >>> append_unused_retval([])
......
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