]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-100146: Steal references from stack when building a list (#100147)
authorL. A. F. Pereira <l.pereira@microsoft.com>
Tue, 3 Jan 2023 18:49:49 +0000 (10:49 -0800)
committerGitHub <noreply@github.com>
Tue, 3 Jan 2023 18:49:49 +0000 (10:49 -0800)
commite6d44407827490a5345e8393fbdc78fd6c14f5b1
tree2f8537e266b484373b806fa7755d9edf40120ca4
parentb3722ca058f6a6d6505cf2ea9ffabaf7fb6b6e19
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.
Include/internal/pycore_list.h
Misc/NEWS.d/next/Core and Builtins/2022-12-09-13-18-42.gh-issue-100146.xLVKg0.rst [new file with mode: 0644]
Objects/listobject.c
Python/bytecodes.c
Python/generated_cases.c.h