This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients rhettinger, serhiy.storchaka
Date 2020-05-03.21:41:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588542089.41.0.502312186848.issue40489@roundup.psfhosted.org>
In-reply-to
Content
In Objects/dictobject.c, if I remove the INCREF/DECREF pair around PyObject_RichCompareBool(), all the tests still pass:

-           Py_INCREF(startkey);
            cmp = PyObject_RichCompareBool(startkey, key, Py_EQ);
-           Py_DECREF(startkey);

It would be nice to have tests demonstrating why it is necessary.  IIRC the reason is that an object could have a custom comparison that clears the enclosing container and frees the element during the comparison.  

Also, it would be nice if PyObject_RichCompareBool() could be redesigned to not fail if a borrowed reference gets deallocated while the function is running.  The incref and decref occur on a hot path, and it is unfortunate that they cause extra writes to objects scattered all over memory, likely causing a lot of cache misses in real programs.
History
Date User Action Args
2020-05-03 21:41:29rhettingersetrecipients: + rhettinger, serhiy.storchaka
2020-05-03 21:41:29rhettingersetmessageid: <1588542089.41.0.502312186848.issue40489@roundup.psfhosted.org>
2020-05-03 21:41:29rhettingerlinkissue40489 messages
2020-05-03 21:41:29rhettingercreate