[issue29476] Simplify set_add_entry()

Raymond Hettinger report at bugs.python.org
Sat Jan 13 15:14:43 EST 2018


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

What I've decided for now is to keep the freeslot reuse logic but in a simpler form. Currently there are two optimizations for rare cases.  The first is reusing a dummy entry -- we'll keep that.  And the second is detecting multiple dummies in a lookup chain and prefering the first in the chain -- I'm going to get rid of this I haven't found any plausible case where it demonstrates value in excess of its cost.

For it to trigger, the set has to have had a growth phase, then a number of subsequent deletions, and then later additions that have multiple collisions with dummy entries, all without any intervening resizes.  Modern sets have a lower fill factor, making this situation even less likely.  Also, modern sets use a series of linear probes making collisions much cheaper.  The benefit is so small and so rare, it possible that the cost of the inner-loop test now exceeds its potential benefit.  Given that the optimization is of questionable worth, I choose to remove it, preferring the simpler inner-loop code.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29476>
_______________________________________


More information about the Python-bugs-list mailing list