Adam Olsen <rha...@gmail.com> added the comment: > 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. _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5186> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com