[Python-Dev] Poll: Py_REPLACE/Py_ASSIGN/etc

Serhiy Storchaka storchaka at gmail.com
Wed Feb 26 10:40:01 CET 2014


There were several suggestions for naming new macros which replace old 
value with new value and then (x)decref old value.

#define Py_XXX(ptr, value)        \
     {                             \
         PyObject *__tmp__ = ptr;  \
         ptr = new_value;          \
         Py_DECREF(__tmp__);       \
     }

Listed in order of receipt:

1. Py_(X)SETREF.
2. Py_(X)ASSIGN.
3. Py_(X)DECREC_REPLACE.
4. Py_REF_ASSIGN (Py_XREF_ASSIGN? Py_REF_XASSIGN?).
5. Py_(X)REPLACE.
6. Py_(X)STORE
7. Py_CLEAR_AND_SET.
8. Py_SET_AND_(X)DECREF.
9. Py_(X)DECREF_AND_ASSIGN.
10. Py_ASSIGN_AND_(X)DECREF.
11. Other...

Let's choose the least confusing names.

See discussions at:

http://bugs.python.org/issue3081
http://bugs.python.org/issue16447
http://bugs.python.org/issue20440
http://comments.gmane.org/gmane.comp.python.devel/145346



More information about the Python-Dev mailing list