Skip to content

Commit dfef986

Browse files
authored
bpo-38588: Optimize list comparison. (GH-17766)
Mitigate performance regression of the list comparison caused by 2d5bf56.
1 parent 2d5bf56 commit dfef986

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Objects/listobject.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,6 +2664,9 @@ list_richcompare(PyObject *v, PyObject *w, int op)
26642664
for (i = 0; i < Py_SIZE(vl) && i < Py_SIZE(wl); i++) {
26652665
PyObject *vitem = vl->ob_item[i];
26662666
PyObject *witem = wl->ob_item[i];
2667+
if (vitem == witem) {
2668+
continue;
2669+
}
26672670

26682671
Py_INCREF(vitem);
26692672
Py_INCREF(witem);

0 commit comments

Comments
 (0)