[Python-Dev] Py_SETREF vs. Py_XSETREF (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Mon Apr 4 05:09:56 EDT 2016
- Previous message (by thread): [Python-Dev] Py_SETREF vs. Py_XSETREF
- Next message (by thread): [Python-Dev] Py_SETREF vs. Py_XSETREF
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 3 April 2016 at 17:32, Serhiy Storchaka <storchaka at gmail.com> wrote:
Originally I proposed a pair of macros for safe reference replacing to reflects the duality of PyDECREF/PyXDECREF. [1], [2] The one should use PyDECREF and the other should use PyXDECREF.
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 PySETREF that uses PyXDECREF is used. Due to adding some overhead in comparison with using PyDECREF, this macros is not used in critical performance code such as PyDictSetItem().
I was one of those arguing for the single macro, and I think Alexander raises a good point in http://bugs.python.org/issue26200#msg262204 that I don't recall seeing in the original discussion: the "X" in the macro serves as a good shorthand for indicating that the code in question isn't closely tracking whether or not manipulated reference might be NULL, and hence may be a good candidate for additional micro-optimisations that keep better track of whether or not the pointer is NULL.
Should we rename PySETREF to PyXSETREF and introduce new PySETREF that uses PyDECREF?
With the single-macro design put into effect and concrete problems arising from that, I'm now more persuaded by the consistency argument than I was originally, so +1 from me for reverting to your original dual-macro proposal.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message (by thread): [Python-Dev] Py_SETREF vs. Py_XSETREF
- Next message (by thread): [Python-Dev] Py_SETREF vs. Py_XSETREF
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]