Commit 800e699c authored by Stefan Behnel's avatar Stefan Behnel

Disable an optimisation that turned out to be a pessimisation (replacing...

Disable an optimisation that turned out to be a pessimisation (replacing literal lists with tuples).
parent 272cc2bb
......@@ -2835,8 +2835,11 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
if value.mult_factor is not None or len(items) > 8:
# Appending wins for short sequences but slows down when multiple resize operations are needed.
# This seems to be a good enough limit that avoids repeated resizing.
if isinstance(value, ExprNodes.ListNode):
# At least avoid the list building and use a faster tuple instead.
if False and isinstance(value, ExprNodes.ListNode):
# One would expect that tuples are more efficient here, but benchmarking with
# Py3.5 and Py3.7 suggests that they are not. Probably worth revisiting at some point.
# Might be related to the usage of PySequence_FAST() in CPython's list.extend(),
# which is probably tuned more towards lists than tuples (and rightly so).
tuple_node = args[1].as_tuple().analyse_types(self.current_env(), skip_children=True)
Visitor.recursively_replace_node(node, args[1], tuple_node)
return 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