[Python-Dev] Py_SETREF vs. Py_XSETREF

MRAB python at mrabarnett.plus.com
Sun Apr 3 09:29:31 EDT 2016


On 2016-04-03 08:32, Serhiy Storchaka wrote:
> Originally I proposed a pair of macros for safe reference replacing to
> reflects the duality of Py_DECREF/Py_XDECREF. [1], [2]  The one should
> use Py_DECREF and the other should use Py_XDECREF.
>
> But then I got a number of voices for the single name [3], and no one
> voice (except mine) for the pair of names. Thus in final patches the
> single name Py_SETREF that uses Py_XDECREF is used. Due to adding some
> overhead in comparison with using Py_DECREF, this macros is not used in
> critical performance code such as PyDict_SetItem().
>
> Now Raymond says that we should have separate Py_SETREF/Py_XSETREF names
> to avoid any overhead. [4]  And so I'm raising this issue on Python-Dev.
>
> Should we rename Py_SETREF to Py_XSETREF and introduce new Py_SETREF
> that uses Py_DECREF?
>
> [1] http://comments.gmane.org/gmane.comp.python.devel/145346
> [2] http://comments.gmane.org/gmane.comp.python.devel/145974
> [3] http://bugs.python.org/issue26200#msg259784
> [4] http://bugs.python.org/issue26200
>
Checking for NULL is convenient (and safer), but, on the other hand, it 
_would_ be consistent with the others.


More information about the Python-Dev mailing list