I dislike PyList_New() + PyList_SET_ITEM() API since the list is immediately tracked by the GC and so calling gc.get_objects() can expose an invalid list object (ex: calling repr(list) can crash). See:
The internal PyObject * _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) function should be made public.
cc @erlend-aasland
UPDATE: I updated the issue to request promoting _PyTuple_FromArray() instead of _PyList_FromArraySteal().
We should also make PyObject* _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n) public.
Can you wait until the new guidelines are approved? Not everyone is happy with the term steal.
Can you wait until the new guidelines are approved?
The name is discussed at capi-workgroup/problems#11 (comment)
Naming is discussed at capi-workgroup/api-evolution#25
pythongh-111489: Add PyList_FromArrayMoveRef() function
@encukou:
Ok, I close the issue.
Let me retry to implement these functions. I reopen the issue.
pythongh-111489: Add PyTuple_FromArray() function
Let's start with the non controversial part: I created #139691 to add PyTuple_FromArray().
I created capi-workgroup/decisions#78 to ask the C API Working Group to decide on the "take ownership" term (Steal or Move).
Oh, the function _PyList_FromArraySteal() was replaced with _PyList_FromStackRefSteal() which gets a const _PyStackRef *src array (commit ab094d1).
gh-111489: Add PyTuple_FromArray() function (#139691)
I close the issue.
I added PyTuple_FromArray() to Python 3.15.
The C API Working Group is against adding PyTuple_FromArraySteal() to the public C API.
pythongh-111489: Remove _PyTuple_FromArray() alias
gh-111489: Remove _PyTuple_FromArray() alias (#139973)
Activity
vstinner commented on Oct 30, 2023
We should also make PyObject* _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n) public.
encukou commented on Oct 30, 2023
Can you wait until the new guidelines are approved? Not everyone is happy with the term steal.
vstinner commented on Oct 30, 2023
The name is discussed at capi-workgroup/problems#11 (comment)
vstinner commented on Dec 11, 2023
Naming is discussed at capi-workgroup/api-evolution#25
pythongh-111489: Add PyList_FromArrayMoveRef() function
pythongh-111489: Add PyList_FromArrayMoveRef() function
pythongh-111489: Add PyList_FromArrayMoveRef() function
pythongh-111489: Add PyList_FromArrayMoveRef() function
vstinner commented on Dec 20, 2023
@encukou:
Ok, I close the issue.
vstinner commented on Oct 7, 2025
Let me retry to implement these functions. I reopen the issue.
pythongh-111489: Add PyTuple_FromArray() function
vstinner commented on Oct 7, 2025
Let's start with the non controversial part: I created #139691 to add PyTuple_FromArray().
vstinner commented on Oct 7, 2025
I created capi-workgroup/decisions#78 to ask the C API Working Group to decide on the "take ownership" term (Steal or Move).
vstinner commented on Oct 10, 2025
Oh, the function _PyList_FromArraySteal() was replaced with _PyList_FromStackRefSteal() which gets a const _PyStackRef *src array (commit ab094d1).
gh-111489: Add PyTuple_FromArray() function (#139691)
vstinner commented on Oct 10, 2025
I close the issue.
I added PyTuple_FromArray() to Python 3.15.
The C API Working Group is against adding PyTuple_FromArraySteal() to the public C API.
pythongh-111489: Remove _PyTuple_FromArray() alias
gh-111489: Remove _PyTuple_FromArray() alias (#139973)