← Back to DAGDA | Support | Source: https://github.com/python/cpython/commit/31aca4bf79217e6ec4c1d056d3ad7ed4dd469c78
Skip to content

Commit 31aca4b

Browse files
orenmnrhettinger
authored andcommitted
bpo-31586: Use _count_element fast path for real dicts.
1 parent c740e4f commit 31aca4b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Modules/_collectionsmodule.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2277,7 +2277,9 @@ _count_elements(PyObject *self, PyObject *args)
22772277
dict_setitem = _PyType_LookupId(&PyDict_Type, &PyId___setitem__);
22782278

22792279
if (mapping_get != NULL && mapping_get == dict_get &&
2280-
mapping_setitem != NULL && mapping_setitem == dict_setitem) {
2280+
mapping_setitem != NULL && mapping_setitem == dict_setitem &&
2281+
PyDict_Check(mapping))
2282+
{
22812283
while (1) {
22822284
/* Fast path advantages:
22832285
1. Eliminate double hashing

0 commit comments

Comments
 (0)