summaryrefslogtreecommitdiff
path: root/Cython/Compiler/ExprNodes.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2020-04-08 10:30:02 +0200
committerStefan Behnel <stefan_ml@behnel.de>2020-04-08 10:30:02 +0200
commit4ef1a091ba19e330eb02e6081839abad3769cd41 (patch)
treedcfe4b8aa828e3707cfd261ffcf7d7c445f1328d /Cython/Compiler/ExprNodes.py
parentc43bd7771fe6fe0064cdfa276f49fd693c277226 (diff)
downloadcython-optimise_pysequence_list.tar.gz
Avoid calling PySequence_List() in some cases where we can see that the argument is a new list already.optimise_pysequence_list
Diffstat (limited to 'Cython/Compiler/ExprNodes.py')
-rw-r--r--Cython/Compiler/ExprNodes.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index 9e94d0bd8..829baeaf0 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -7797,8 +7797,11 @@ class SequenceNode(ExprNode):
starred_target.allocate(code)
target_list = starred_target.result()
- code.putln("%s = PySequence_List(%s); %s" % (
+ code.putln("%s = %s(%s); %s" % (
target_list,
+ "__Pyx_PySequence_ListKeepNew" if (
+ not iterator_temp and rhs.is_temp and rhs.type in (py_object_type, list_type))
+ else "PySequence_List",
iterator_temp or rhs.py_result(),
code.error_goto_if_null(target_list, self.pos)))
starred_target.generate_gotref(code)
@@ -8531,7 +8534,9 @@ class MergedSequenceNode(ExprNode):
else:
code.putln("%s = %s(%s); %s" % (
self.result(),
- 'PySet_New' if is_set else 'PySequence_List',
+ 'PySet_New' if is_set
+ else "__Pyx_PySequence_ListKeepNew" if item.is_temp and item.type in (py_object_type, list_type)
+ else "PySequence_List",
item.py_result(),
code.error_goto_if_null(self.result(), self.pos)))
self.generate_gotref(code)