[Python-Dev] New poll about a macro for safe reference replacing

Nick Coghlan ncoghlan at gmail.com
Thu Dec 17 01:22:31 EST 2015


On 17 December 2015 at 00:12, Serhiy Storchaka <storchaka at gmail.com> wrote:
> The problem is only in the macro name. There are objections against any
> proposed name, and no one name gained convincing majority.
>
> Here are names gained the largest numbers of votes plus names proposed
> during polling.
>
> 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)

-0 for a Py_SETREF/Py_XSETREF pair (the problem I see is that it's
unclear that it's the target location that's allowed to be NULL in the
latter case)

> 2. Py_DECREF_REPLACE

-1: too long

> 3. Py_REPLACE

+0 if it uses Py_DECREF on the previous value as part of a
Py_REPLACE/Py_SETREF pair

However, I'm not sure we need the micro-optimisation offering by
skipping the "Is the previous value NULL?" check, and it's always
easier to add an API later than it is to remove one.

> 4. Py_SET_POINTER

-1: As Victor says, "pointer" tends to mean "void *" in out C code,
not "PyObject *".

> 5. Py_SET_ATTR

-1: This operation is useful for updating any reachable reference to
another object, not just attributes

> 6. Py_REPLACE_REF

-0: this is like 3, only with a slightly longer name

I'm also in favour of Serhiy claiming the casting vote if there's no
clear consensus :)

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list