]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Aggressive reordering of dict comparisons. In case of collision, it stands
authorTim Peters <tim.peters@gmail.com>
Sun, 13 May 2001 06:43:53 +0000 (06:43 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 13 May 2001 06:43:53 +0000 (06:43 +0000)
commit342c65e19ac0cc47bf2b21026c76e63440b23748
tree55dc4a4a5302dbd46e54f0e17db376d028653aa3
parent2f228e75e4d5ac8c3eb4a6334dbc43243bff1095
Aggressive reordering of dict comparisons.  In case of collision, it stands
to reason that me_key is much more likely to match the key we're looking
for than to match dummy, and if the key is absent me_key is much more
likely to be NULL than dummy:  most dicts don't even have a dummy entry.
Running instrumented dict code over the test suite and some apps confirmed
that matching dummy was 200-300x less frequent than matching key in
practice.  So this reorders the tests to try the common case first.
It can lose if a large dict with many collisions is mostly deleted, not
resized, and then frequently searched, but that's hardly a case we
should be favoring.
Objects/dictobject.c