Feature or enhancement
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:
PyObject *PyList_GetItemRef(PyObject *list, Py_ssize_t index)
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.
Linked PRs
Feature or enhancement
The free-threaded builds need a variant of
PyList_GetItemthat returns a strong reference instead of a borrowed reference for thread-safety reasons. PEP 703 proposedPyList_FetchItem, but since thenPyDict_GetItemRefand functions with similar signatures have been added.This proposes
PyList_GetItemRefwith the following signature:Return a strong reference to the object at position index in the list pointed to by list. If
indexis out of bounds (<0 or >=len(list)), return NULL and set an IndexError. Iflistis not a list instance, return NULL and set a TypeError.Linked PRs
PyList_GetItemReffunction #114504