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. This reduces overhead on tight comparison loops, improving :class:`list` sort performance by approximately 1%.
Comment thread
benediktjohannes marked this conversation as resolved.
Outdated
Patch by Benedikt Johannes.
2 changes: 1 addition & 1 deletion Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2774,8 +2774,8 @@ unsafe_object_compare(PyObject *v, PyObject *w, MergeState *ms)
}
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