[issue42294] [C API] Add new C functions with more regular reference counting like PyTuple_GetItemRef()

Serhiy Storchaka report at bugs.python.org
Mon Nov 9 17:22:45 EST 2020


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I concur with Mark.

If you want to work only with non-borrowed references, use PySequence_GetItem() and PySequence_SetItem(). It has a cost: it is slower and needs checking errors. If you need more performant solution and binary compatibility across versions, use PyTuple_GetItem() and PyTuple_SetItem() (borrowed references is the part of optimization). If you don't need binary compatibility, but need speed, use macros.

And no need to expand the C API. It is already large enough.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42294>
_______________________________________


More information about the Python-bugs-list mailing list