diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-09-27 03:45:57 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2017-09-27 03:45:57 (GMT) |
commit | a1c49f6f09150f70f063417c8d67a38e59dde7ed (patch) | |
tree | 678b9ccd143b42a3939318767e528021339b20f9 | |
parent | 69b2dc8637ba924d78f9869be592c5a545510f10 (diff) | |
download | cpython-a1c49f6f09150f70f063417c8d67a38e59dde7ed.zip cpython-a1c49f6f09150f70f063417c8d67a38e59dde7ed.tar.gz cpython-a1c49f6f09150f70f063417c8d67a38e59dde7ed.tar.bz2 |
[3.6] bpo-31586: Use _count_element fast path for real dicts. (#3776)
(cherry picked from commit 31aca4bf79217e6ec4c1d056d3ad7ed4dd469c78)
-rw-r--r-- | Modules/_collectionsmodule.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index e7a24f3..af20d6e 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -2276,7 +2276,9 @@ _count_elements(PyObject *self, PyObject *args) dict_setitem = _PyType_LookupId(&PyDict_Type, &PyId___setitem__); if (mapping_get != NULL && mapping_get == dict_get && - mapping_setitem != NULL && mapping_setitem == dict_setitem) { + mapping_setitem != NULL && mapping_setitem == dict_setitem && + PyDict_Check(mapping)) + { while (1) { /* Fast path advantages: 1. Eliminate double hashing |