Commit d540efe6 authored by Stefan Behnel's avatar Stefan Behnel

use tuple instead of list for f-string joining because it is faster to...

use tuple instead of list for f-string joining because it is faster to allocate - speedup can be up to 20%
parent 78ef92a2
...@@ -2980,7 +2980,7 @@ class JoinedStrNode(ExprNode): ...@@ -2980,7 +2980,7 @@ class JoinedStrNode(ExprNode):
num_items = len(self.values) num_items = len(self.values)
list_var = code.funcstate.allocate_temp(py_object_type, manage_ref=True) list_var = code.funcstate.allocate_temp(py_object_type, manage_ref=True)
code.putln('%s = PyList_New(%s); %s' % ( code.putln('%s = PyTuple_New(%s); %s' % (
list_var, list_var,
num_items, num_items,
code.error_goto_if_null(list_var, self.pos))) code.error_goto_if_null(list_var, self.pos)))
...@@ -2990,7 +2990,7 @@ class JoinedStrNode(ExprNode): ...@@ -2990,7 +2990,7 @@ class JoinedStrNode(ExprNode):
node.generate_evaluation_code(code) node.generate_evaluation_code(code)
node.make_owned_reference(code) node.make_owned_reference(code)
code.put_giveref(node.py_result()) code.put_giveref(node.py_result())
code.putln('PyList_SET_ITEM(%s, %s, %s);' % (list_var, i, node.py_result())) code.putln('PyTuple_SET_ITEM(%s, %s, %s);' % (list_var, i, node.py_result()))
node.generate_post_assignment_code(code) node.generate_post_assignment_code(code)
node.free_temps(code) node.free_temps(code)
......
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