Skip to content

Commit 01ae32b

Browse files
authored
Merge pull request #200 from python/master
bpo-39425: Fix list.count performance regression (pythonGH-18119)
2 parents 25cb001 + 14d80d0 commit 01ae32b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Objects/listobject.c

+4
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,10 @@ list_count(PyListObject *self, PyObject *value)
25842584

25852585
for (i = 0; i < Py_SIZE(self); i++) {
25862586
PyObject *obj = self->ob_item[i];
2587+
if (obj == value) {
2588+
count++;
2589+
continue;
2590+
}
25872591
Py_INCREF(obj);
25882592
int cmp = PyObject_RichCompareBool(obj, value, Py_EQ);
25892593
Py_DECREF(obj);

0 commit comments

Comments
 (0)