mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-31586: Use _count_element fast path for real dicts.
This commit is contained in:
parent
c740e4fe8a
commit
31aca4bf79
1 changed files with 3 additions and 1 deletions
|
@ -2277,7 +2277,9 @@ _count_elements(PyObject *self, PyObject *args)
|
||||||
dict_setitem = _PyType_LookupId(&PyDict_Type, &PyId___setitem__);
|
dict_setitem = _PyType_LookupId(&PyDict_Type, &PyId___setitem__);
|
||||||
|
|
||||||
if (mapping_get != NULL && mapping_get == dict_get &&
|
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) {
|
while (1) {
|
||||||
/* Fast path advantages:
|
/* Fast path advantages:
|
||||||
1. Eliminate double hashing
|
1. Eliminate double hashing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue