New submission from Dennis Sweeney <sweeney.dennis...@gmail.com>:
The following tiny change: diff --git a/Objects/listobject.c b/Objects/listobject.c index 3c39c6444b..3ac03b71d0 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2643,8 +2643,7 @@ list_richcompare(PyObject *v, PyObject *w, int op) Py_INCREF(vitem); Py_INCREF(witem); - int k = PyObject_RichCompareBool(vl->ob_item[i], - wl->ob_item[i], Py_EQ); + int k = PyObject_RichCompareBool(vitem, witem, Py_EQ); Py_DECREF(vitem); Py_DECREF(witem); if (k < 0) Creates the following performance improvement: Before: > .\python.bat -m timeit -s "A = list(range(10**7)); B = list(range(10**7))" > "A==B" 2 loops, best of 5: 134 msec per loop > .\python.bat -m timeit -s "A = list(range(10**7)); B = list(range(10**7))" > "A==B" 2 loops, best of 5: 134 msec per loop After: > .\python.bat -m timeit -s "A = list(range(10**7)); B = list(range(10**7))" > "A==B" 2 loops, best of 5: 126 msec per loop > .\python.bat -m timeit -s "A = list(range(10**7)); B = list(range(10**7))" > "A==B" 2 loops, best of 5: 126 msec per loop ---------- components: Interpreter Core messages: 362566 nosy: Dennis Sweeney priority: normal severity: normal status: open title: Speed up list.__eq__ by about 6% type: performance versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39737> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com