Message81700
> At four bits, you may be throwing away information and I don't think
> that's cool. Even if some selected timings are better with more bits
> shifted, all you're really showing is that there is more randomness in
> the upper bits than the lower ones. But that doesn't mean than the
> lower one contribute nothing at all.
On the contrary, the expected collision rate for a half-full dictionary
is about 21%, whereas I'm getting less than 5%. I'm taking advantage of
the sequentiality of addresses, just as int and str hashes do for their
values.
However, you're right that it's only one use case. Although creating a
burst of objects for a throw-away set may itself be common, it's
typically with int or str, and doing it with custom objects is
presumably fairly rare; certainly not a good microbenchmark for the rest
of the interpreter.
Creating a list of 100000 objects, then shuffling and picking a few
increases my collision rate back up to 21%. That should more accurately
reflect a long-running program using custom objects as keys in a dict.
That said, I still prefer the simplicity of a rotate. Adding an
arbitrary set of OR, XOR, or add makes me uneasy; I know enough to do
them wrong (reduce entropy), but not enough to do them right. |
|
Date |
User |
Action |
Args |
2009-02-12 01:07:12 | Rhamphoryncus | set | recipients:
+ Rhamphoryncus, rhettinger, jcea, chemacortes, mark.dickinson, pitrou |
2009-02-12 01:07:11 | Rhamphoryncus | set | messageid: <1234400831.82.0.640693928521.issue5186@psf.upfronthosting.co.za> |
2009-02-12 01:07:10 | Rhamphoryncus | link | issue5186 messages |
2009-02-12 01:07:07 | Rhamphoryncus | create | |
|