bpo-39425: Fix list.count performance regression (GH-18119)

https://bugs.python.org/issue39425



Automerge-Triggered-By: @pablogsal
This commit is contained in:
Dong-hee Na 2020-01-23 02:36:54 +09:00 committed by Miss Islington (bot)
parent 5bbac8cbdf
commit 14d80d0b60
1 changed files with 4 additions and 0 deletions

View File

@ -2584,6 +2584,10 @@ list_count(PyListObject *self, PyObject *value)
for (i = 0; i < Py_SIZE(self); i++) {
PyObject *obj = self->ob_item[i];
if (obj == value) {
count++;
continue;
}
Py_INCREF(obj);
int cmp = PyObject_RichCompareBool(obj, value, Py_EQ);
Py_DECREF(obj);