]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38588: Optimize list comparison. (GH-17766)
authorInada Naoki <songofacandy@gmail.com>
Tue, 31 Dec 2019 01:58:37 +0000 (10:58 +0900)
committerGitHub <noreply@github.com>
Tue, 31 Dec 2019 01:58:37 +0000 (10:58 +0900)
Mitigate performance regression of the list comparison caused by 2d5bf56.

Objects/listobject.c

index abe2604573f95a040110559bfebf56419eac806f..bc8425cae63e12966b1044cfbcd221d1c32142e8 100644 (file)
@@ -2664,6 +2664,9 @@ list_richcompare(PyObject *v, PyObject *w, int op)
     for (i = 0; i < Py_SIZE(vl) && i < Py_SIZE(wl); i++) {
         PyObject *vitem = vl->ob_item[i];
         PyObject *witem = wl->ob_item[i];
+        if (vitem == witem) {
+            continue;
+        }
 
         Py_INCREF(vitem);
         Py_INCREF(witem);