]> granicus.if.org Git - python/commit
Instead of XORed indicies, switch to a hybrid of linear probing and open addressing.
authorRaymond Hettinger <python@rcn.com>
Mon, 2 Sep 2013 10:23:21 +0000 (03:23 -0700)
committerRaymond Hettinger <python@rcn.com>
Mon, 2 Sep 2013 10:23:21 +0000 (03:23 -0700)
commita35adf5b0984758ddc64ced81cfac56fa15fd94a
treed6a2ae54e7b853d0e618909a96784c1b749ff19e
parenta661f4531e2c8d189dc4a6c22ce74d2bfd18cbcd
Instead of XORed indicies, switch to a hybrid of linear probing and open addressing.

Modern processors tend to make consecutive memory accesses cheaper than
random probes into memory.

Small sets can fit into L1 cache, so they get less benefit.  But they do
come out ahead because the consecutive probes don't probe the same key
more than once and because the randomization step occurs less frequently
(or not at all).

For the open addressing step, putting the perturb shift before the index
calculation gets the upper bits into play sooner.
Objects/setobject.c