Commit 00bd02fd authored by Stefan Behnel's avatar Stefan Behnel

exclude optimised builtin methods from being the Python method call...

exclude optimised builtin methods from being the Python method call optimisation (previously broke code generation)
parent 05509f78
......@@ -4201,15 +4201,20 @@ class FinalOptimizePhase(Visitor.CythonTransform, Visitor.NodeRefCleanupMixin):
may_be_a_method = True
if function.type is Builtin.type_type:
may_be_a_method = False
elif function.is_attribute:
if function.entry.type.is_cfunction:
# optimised builtin method
may_be_a_method = False
elif function.is_name:
if function.entry.is_builtin:
entry = function.entry
if entry.is_builtin or entry.type.is_cfunction:
may_be_a_method = False
elif function.entry.cf_assignments:
elif entry.cf_assignments:
# local functions/classes are definitely not methods
non_method_nodes = (ExprNodes.PyCFunctionNode, ExprNodes.ClassNode, ExprNodes.Py3ClassNode)
may_be_a_method = any(
assignment.rhs and not isinstance(assignment.rhs, non_method_nodes)
for assignment in function.entry.cf_assignments)
for assignment in entry.cf_assignments)
if may_be_a_method:
node = self.replace(node, ExprNodes.PyMethodCallNode.from_node(
node, function=function, arg_tuple=node.arg_tuple, type=node.type))
......
......@@ -83,6 +83,16 @@ def dict_call_kwargs():
return d
def items_of_dict_call():
"""
>>> items_of_dict_call()
[('answer1', 42), ('answer2', 42), ('parrot1', u'resting'), ('parrot2', u'resting')]
"""
kwargs = dict(parrot1=u"resting", answer1=42)
items = dict(kwargs.items(), parrot2=u"resting", answer2=42, **kwargs).items()
return sorted(items)
def item_creation_sideeffect(L, sideeffect, unhashable):
"""
>>> def sideeffect(x):
......
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