diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2014-02-14 19:33:22 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2014-02-14 19:33:22 +0100 |
commit | d609632af1c0c0249172ffd6c5178456bd5b37ca (patch) | |
tree | 488116f903a6bad670f30c8556052a3a8469ccb3 | |
parent | b8d4929e51c678fc870953490e60471d46e4a083 (diff) | |
download | cython-d609632af1c0c0249172ffd6c5178456bd5b37ca.tar.gz |
replace frozenset([...]) by frozenset((...))
--HG--
extra : amend_source : 7954c320c39d51cde9ac7d4368258ceb56a3bc2f
-rw-r--r-- | Cython/Compiler/Optimize.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 88a857e6b..5e5b12767 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -1598,6 +1598,15 @@ class EarlyReplaceBuiltinCalls(Visitor.EnvTransform): return ExprNodes.AsTupleNode(node.pos, arg=result) return node + def _handle_simple_function_frozenset(self, node, pos_args): + """Replace frozenset([...]) by frozenset((...)) as tuples are more efficient. + """ + if len(pos_args) != 1: + return node + if isinstance(pos_args[0], ExprNodes.ListNode): + pos_args[0] = pos_args[0].as_tuple() + return node + def _handle_simple_function_list(self, node, pos_args): if not pos_args: return ExprNodes.ListNode(node.pos, args=[], constant_result=[]) |