summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2019-12-31 01:58:37 (GMT)
committerGitHub <noreply@github.com>2019-12-31 01:58:37 (GMT)
commitdfef986f12dd92bd6434117bba0db3cbb4e65243 (patch)
treef4cea7b45fd26210bf9fdfd1b01effab5212097a /Objects/listobject.c
parent2d5bf568eaa5059402ccce9ba5a366986ba27c8a (diff)
downloadcpython-dfef986f12dd92bd6434117bba0db3cbb4e65243.zip
cpython-dfef986f12dd92bd6434117bba0db3cbb4e65243.tar.gz
cpython-dfef986f12dd92bd6434117bba0db3cbb4e65243.tar.bz2
bpo-38588: Optimize list comparison. (GH-17766)
Mitigate performance regression of the list comparison caused by 2d5bf56.
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index abe2604..bc8425c 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -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);