question: why isn't a byte of a hash more uniform? how could I improve my code to cure that?

Peter Otten __peter__ at web.de
Fri Aug 7 16:27:26 EDT 2009


Dave Angel wrote:

[clever analysis snipped]

> I'd use digest() instead of hexdigest(), and of course reduce the
> subscript  to 63 or less.

OP: You could also try

hash(line) % 4

While AFAIK it doesn't make promises about randomness it might still be good 
enough in practice.

Peter





More information about the Python-list mailing list