mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-39425: Fix list.count performance regression (GH-18119)
https://bugs.python.org/issue39425 Automerge-Triggered-By: @pablogsal
This commit is contained in:
parent
5bbac8cbdf
commit
14d80d0b60
1 changed files with 4 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue