GeezerVison is showing github.com — Duplicated lookup on unicodekeys_lookup_unicode · Issue #104717 · python/cpython
Duplicated lookup on unicodekeys_lookup_unicode #104717DescriptionThere are duplicated lookups on unicodekeys_lookup_unicode.
I am trying to understand this code as manual loop unrolling for performance. but I am not sure that it is intended.
|
ix = dictkeys_get_index(dk, i); |
|
if (ix >= 0) { |
|
PyDictUnicodeEntry *ep = &ep0[ix]; |
|
assert(ep->me_key != NULL); |
|
assert(PyUnicode_CheckExact(ep->me_key)); |
|
if (ep->me_key == key || |
|
(unicode_get_hash(ep->me_key) == hash && unicode_eq(ep->me_key, key))) { |
|
return ix; |
|
} |
|
} |
|
else if (ix == DKIX_EMPTY) { |
|
return DKIX_EMPTY; |
|
} |
|
perturb >>= PERTURB_SHIFT; |
|
i = mask & (i*5 + perturb + 1); |
|
ix = dictkeys_get_index(dk, i); |
|
if (ix >= 0) { |
|
PyDictUnicodeEntry *ep = &ep0[ix]; |
|
assert(ep->me_key != NULL); |
|
assert(PyUnicode_CheckExact(ep->me_key)); |
|
if (ep->me_key == key || |
|
(unicode_get_hash(ep->me_key) == hash && unicode_eq(ep->me_key, key))) { |
|
return ix; |
|
} |
|
} |
|
else if (ix == DKIX_EMPTY) { |
|
return DKIX_EMPTY; |
|
} |
|
perturb >>= PERTURB_SHIFT; |
|
i = mask & (i*5 + perturb + 1); |
First introduced from f8a95df
Please let me know this that is intended.
Linked PRs
Activitycorona10 commented on May 21, 2023 methane commented on May 21, 2023 Yes, this is intended, manual loop unrolling.
This is the hottest path in dictobject.c.
I don't remember tha actual number of performance gain, but I had confirmed that this had some gain. corona10 commented on May 21, 2023 Okay then I will close the issue.
Yes, this is intended, manual loop unrolling.
It will be great if there is a comment about this.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|