SIGN IN SIGN UP
python / cpython UNCLAIMED

The Python programming language

0 0 519 Python

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.
T
Tim Peters committed
342c65e19ac0cc47bf2b21026c76e63440b23748
Parent: 2f228e7