Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The function ``unsafe_object_compare()`` in :file:`Objects/listobject.c` has been optimized to avoid unnecessary reference count decrements on boolean results.
Patch by Benedikt Johannes.
Comment thread
picnixz marked this conversation as resolved.
Outdated
3 changes: 2 additions & 1 deletion Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2771,11 +2771,12 @@ unsafe_object_compare(PyObject *v, PyObject *w, MergeState *ms)

if (PyBool_Check(res_obj)) {
res = (res_obj == Py_True);
assert(_Py_IsImmortal(res_obj));
}
else {
res = PyObject_IsTrue(res_obj);
Py_DECREF(res_obj);
}
Py_DECREF(res_obj);

/* Note that we can't assert
* res == PyObject_RichCompareBool(v, w, Py_LT);
Expand Down
Loading