-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Closed
Labels
Description
I propose to add a new PyTuple_GetItemRef() function, similar to PyTuple_GetItem() but return a strong reference instead of a borrowed reference.
Other functions were added recently to return a strong reference:
- PyDict_GetItemRef(), PyDict_GetItemStringRef() -- issue C API: Add PyDict_GetItemRef() function #106004
- PyList_GetItemRef() -- issue Add
PyList_GetItemRef
, a variant ofPyList_GetItem
that returns a strong reference #114329 - PyWeakref_GetRef() -- issue C API: Add PyWeakref_GetRef() function #105927
- PyImport_AddModuleRef() -- issue C API: Add PyImport_AddModuleRef() function #105922
I already proposed adding PyTuple_GetItemRef() in 2020, but the idea was rejected: issue gh-86460. Since 2020, Free Threading (PEP 703) was added to Python and borrowed references don't play well with Free Threading.