Message367997
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. |
|
Date |
User |
Action |
Args |
2020-05-03 21:41:29 | rhettinger | set | recipients:
+ rhettinger, serhiy.storchaka |
2020-05-03 21:41:29 | rhettinger | set | messageid: <1588542089.41.0.502312186848.issue40489@roundup.psfhosted.org> |
2020-05-03 21:41:29 | rhettinger | link | issue40489 messages |
2020-05-03 21:41:29 | rhettinger | create | |
|