diff options
author | L. A. F. Pereira <l.pereira@microsoft.com> | 2023-01-03 18:49:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-03 18:49:49 (GMT) |
commit | e6d44407827490a5345e8393fbdc78fd6c14f5b1 (patch) | |
tree | 2f8537e266b484373b806fa7755d9edf40120ca4 /Include/internal | |
parent | b3722ca058f6a6d6505cf2ea9ffabaf7fb6b6e19 (diff) | |
download | cpython-e6d44407827490a5345e8393fbdc78fd6c14f5b1.zip cpython-e6d44407827490a5345e8393fbdc78fd6c14f5b1.tar.gz cpython-e6d44407827490a5345e8393fbdc78fd6c14f5b1.tar.bz2 |
gh-100146: Steal references from stack when building a list (#100147)
When executing the BUILD_LIST opcode, steal the references from the stack,
in a manner similar to the BUILD_TUPLE opcode. Implement this by offloading
the logic to a new private API, _PyList_FromArraySteal(), that works similarly
to _PyTuple_FromArraySteal().
This way, instead of performing multiple stack pointer adjustments while the
list is being initialized, the stack is adjusted only once and a fast memory
copy operation is performed in one fell swoop.
Diffstat (limited to 'Include/internal')
-rw-r--r-- | Include/internal/pycore_list.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Include/internal/pycore_list.h b/Include/internal/pycore_list.h index 628267c..2fcbe12 100644 --- a/Include/internal/pycore_list.h +++ b/Include/internal/pycore_list.h @@ -75,6 +75,8 @@ typedef struct { PyListObject *it_seq; /* Set to NULL when iterator is exhausted */ } _PyListIterObject; +extern PyObject *_PyList_FromArraySteal(PyObject *const *src, Py_ssize_t n); + #ifdef __cplusplus } #endif |