summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-01-22 18:11:22 (GMT)
committerPablo Galindo <Pablogsal@gmail.com>2020-01-22 18:11:22 (GMT)
commitfdb21609d944941f0732df72dc3d07a7a9a7efea (patch)
tree02af74b84d16be8d382eb484f7cb764ee874f567 /Objects
parentf84f65be5602e561fef04b66bb487fbc4e560db5 (diff)
downloadcpython-fdb21609d944941f0732df72dc3d07a7a9a7efea.zip
cpython-fdb21609d944941f0732df72dc3d07a7a9a7efea.tar.gz
cpython-fdb21609d944941f0732df72dc3d07a7a9a7efea.tar.bz2
bpo-39425: Fix list.count performance regression (GH-18119) (GH-18120)
https://bugs.python.org/issue39425 Automerge-Triggered-By: @pablogsal (cherry picked from commit 14d80d0b605d8b148e14458e4c1853a940071462) Co-authored-by: Dong-hee Na <donghee.na92@gmail.com> Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r--Objects/listobject.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index d506c08..73afc44 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -2586,6 +2586,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);