diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2014-08-17 13:37:40 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2014-08-17 13:37:40 +0200 |
commit | 159f48a995d425cc891c3ac50f99b47edf39e9de (patch) | |
tree | fd65cc2c55b33021c2deeed67661a81836aee5df | |
parent | aee8b65a027bd2cfa4fe570fdbb070b807b5e4e0 (diff) | |
download | cython-159f48a995d425cc891c3ac50f99b47edf39e9de.tar.gz |
exclude local Python classes from method call optimisation (even with metaclasses in place, they are fairly unlikely to return methods)
-rw-r--r-- | Cython/Compiler/Optimize.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 9a817e520..be443ac13 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -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( |