The free-threaded builds need a variant of PyList_GetItem that returns a strong reference instead of a borrowed reference for thread-safety reasons. PEP 703 proposed PyList_FetchItem, but since then PyDict_GetItemRef and functions with similar signatures have been added.
This proposes PyList_GetItemRef with the following signature:
Return a strong reference to the object at position index in the list pointed to by list. If index is out of bounds (<0 or >=len(list)), return NULL and set an IndexError. If list is not a list instance, return NULL and set a TypeError.
Activity
colesbury commented on Jan 19, 2024
C-API working group issue: capi-workgroup/decisions#9
Eclips4 commented on Jan 19, 2024
Just FYI, feature requests do not need version label :)
pythongh-114329: Add `PyList_GetItemRef` function
Merge branch 'main' into pythongh-114329-list
gh-114329: Add `PyList_GetItemRef` function (GH-114504)
encukou commented on Feb 2, 2024
Thank you!
pythongh-114329: Add `PyList_GetItemRef` function (pythonGH-114504)
pythongh-114329: Add `PyList_GetItemRef` function (pythonGH-114504)
pythongh-114329: Fix PyList_GetItemRef() limited C API definition
pythongh-114329: Fix PyList_GetItemRef() limited C API definition
gh-114329: Fix PyList_GetItemRef() limited C API definition (#117520)
pythongh-114329: Fix PyList_GetItemRef() limited C API definition (py…