[issue26200] SETREF adds unnecessary work in some cases

Serhiy Storchaka report at bugs.python.org
Mon Nov 9 17:09:20 EST 2020


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

Py_SETREF() is simple wrappers around Py_DECREF() and assignment. If there are macros in Rust it is better to implement Py_SETREF() as Rust macro.

Py_SETREF() was not added to the limited API for reason. If arguments against Py_SETREF() are still valid, the same arguments are applicable to Py_SetRef(). And even if Py_SETREF() will be added to the limited C API I do not think that there is a need of adding Py_SetRef(). It is more cumbersome (additional &), slower and affects the optimization of surrounded code (pointer cannot be in register), and does not have any advantage in addition to the macro.

This issue was closed 4 years ago. Please open a new issue for Py_SetRef().

----------

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


More information about the Python-bugs-list mailing list