[issue26200] SETREF adds unnecessary work in some cases
Alexander Belopolsky
report at bugs.python.org
Tue Mar 22 13:29:31 EDT 2016
Alexander Belopolsky added the comment:
I am late to this discussion, but FWIW, I would like to back Raymond up. For me, Py_XDECREF is usually a sign of lazy programming and an optimization opportunity. In many cases I've seen, Py_XDECREF is used under a "done:" label and can be optimized by strategically placing Py_DECREFs before (error) returns while keeping track of what is and what is not initialized. In addition to an extra null check, Py_XDECREF typically requires a NULL initialization which can be avoided with a more thoughtful code structure.
All in all, Py_XDECREF rightfully stands out with an "X" spelling. I don't want to see it hidden behind an innocent-looking convenience macro.
I am ±0 on the XSETREF variant, but I think SETREF should use DECREF.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26200>
_______________________________________
More information about the Python-bugs-list
mailing list