You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C API] Make _PyTuple_FromArray() function public #111489
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:
Activity
vstinner commentedon Oct 30, 2023
We should also make
PyObject* _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n)public.encukou commentedon Oct 30, 2023
Can you wait until the new guidelines are approved? Not everyone is happy with the term steal.
vstinner commentedon Oct 30, 2023
The name is discussed at capi-workgroup/problems#11 (comment)
vstinner commentedon 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 commentedon Dec 20, 2023
@encukou:
Ok, I close the issue.
vstinner commentedon Oct 7, 2025
Let me retry to implement these functions. I reopen the issue.
pythongh-111489: Add PyTuple_FromArray() function
vstinner commentedon Oct 7, 2025
Let's start with the non controversial part: I created #139691 to add
PyTuple_FromArray().vstinner commentedon 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).
[-][C API] Make _PyList_FromArraySteal() function public[/-][+][C API] Make _PyList_FromArray() function public[/+][-][C API] Make _PyList_FromArray() function public[/-][+][C API] Make _PyTuple_FromArray() function public[/+]vstinner commentedon Oct 10, 2025
Oh, the function
_PyList_FromArraySteal()was replaced with_PyList_FromStackRefSteal()which gets aconst _PyStackRef *srcarray (commit ab094d1).gh-111489: Add PyTuple_FromArray() function (#139691)
vstinner commentedon 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)