[Python-Dev] Py_SETREF again

Serhiy Storchaka storchaka at gmail.com
Fri Feb 12 04:45:27 EST 2016


Sorry to bringing this up again. I was hoping we were done with that.

When discussing the name of the Py_SETREF macro I was supposed to add a 
pair of macros: for Py_DECREF and Py_XDECREF. But I got a lot of 
opinions to be limited to only one macro.

On 28.02.14 15:58, Kristján Valur Jónsson wrote:
 > Also, for the equivalence to hold there is no separate Py_XSETREF, the X
 > behaviour is implied, which I favour.  Enough of this X-proliferation
 > already!

On 16.12.15 16:53, Random832 wrote:
 > I think "SET" names imply that it's safe if the original
 > reference is NULL. This isn't an objection to the names, but if
 > it is given one of those names I think it should use Py_XDECREF.

It was my initial intension. But then I had got a number of voices for 
single macros.

On 16.12.15 23:16, Victor Stinner wrote:
 > I would prefer a single macro to avoid bugs, I don't think that such
 > macro has a critical impact on performances. It's more designed for
 > safety, no?

On 17.12.15 08:22, Nick Coghlan wrote:
 >> 1. Py_SETREF
 >
 > +1 if it always uses Py_XDECREF on the previous value (as I'd expect
 > this to work even if the previous value was NULL)

There was no (besides my) clearly expressed vote for two macros.
As a result I have replaced both Py_DECREF and Py_XDECREF with the macro 
that always uses Py_XDECREF.

Now Raymond, who was not involved in the previous discussions, expressed 
the view that we should to rename Py_SETREF to Py_XSETREF and add new 
Py_SETREF that uses Py_DECREF for using in the code that used Py_DECREF 
previously. [1]

We should discuss the need for this, and may be re-discuss the names for 
the macros.

[1] http://bugs.python.org/issue26200



More information about the Python-Dev mailing list