diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2020-01-22 17:36:54 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-01-22 17:36:54 (GMT) |
commit | 14d80d0b605d8b148e14458e4c1853a940071462 (patch) | |
tree | 33744b05eb3ab98d8c74a25c998173aad5cc27ee /Objects | |
parent | 5bbac8cbdf140ebce446ea4e7db2b20a5d7b8402 (diff) | |
download | cpython-14d80d0b605d8b148e14458e4c1853a940071462.zip cpython-14d80d0b605d8b148e14458e4c1853a940071462.tar.gz cpython-14d80d0b605d8b148e14458e4c1853a940071462.tar.bz2 |
bpo-39425: Fix list.count performance regression (GH-18119)
https://bugs.python.org/issue39425
Automerge-Triggered-By: @pablogsal
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/listobject.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index bc8425c..a4e90db 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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); |