diff options
author | Oren Milman <orenmn@gmail.com> | 2017-09-27 03:18:21 (GMT) |
---|---|---|
committer | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2017-09-27 03:18:21 (GMT) |
commit | 31aca4bf79217e6ec4c1d056d3ad7ed4dd469c78 (patch) | |
tree | 04467eb09a25256a45ced3ddbd1cd88cfa922b8f | |
parent | c740e4fe8a9bc5815dc18c38d7f7600b128c3c51 (diff) | |
download | cpython-31aca4bf79217e6ec4c1d056d3ad7ed4dd469c78.zip cpython-31aca4bf79217e6ec4c1d056d3ad7ed4dd469c78.tar.gz cpython-31aca4bf79217e6ec4c1d056d3ad7ed4dd469c78.tar.bz2 |
bpo-31586: Use _count_element fast path for real dicts.
-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 e78399d..b6cceee 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -2277,7 +2277,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 |