Commit 159f48a9 authored by Stefan Behnel's avatar Stefan Behnel

exclude local Python classes from method call optimisation (even with...

exclude local Python classes from method call optimisation (even with metaclasses in place, they are fairly unlikely to return methods)
parent aee8b65a
......@@ -3774,9 +3774,10 @@ class FinalOptimizePhase(Visitor.CythonTransform, Visitor.NodeRefCleanupMixin):
if function.entry.is_builtin:
may_be_a_method = False
elif function.cf_state:
# local functions are definitely not methods
# 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, ExprNodes.PyCFunctionNode)
assignment.rhs and not isinstance(assignment.rhs, non_method_nodes)
for assignment in function.cf_state)
if may_be_a_method:
node = self.replace(node, ExprNodes.PyMethodCallNode.from_node(
......
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