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

Commit a1c49f6

Browse files
miss-islingtonrhettinger
authored andcommitted
[3.6] bpo-31586: Use _count_element fast path for real dicts. (#3776)
(cherry picked from commit 31aca4b)
1 parent 69b2dc8 commit a1c49f6

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
@@ -2276,7 +2276,9 @@ _count_elements(PyObject *self, PyObject *args)
22762276
dict_setitem = _PyType_LookupId(&PyDict_Type, &PyId___setitem__);
22772277

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

0 commit comments

Comments
 (0)