On Mar 15, 2007, at 13:09 , Dan Williams wrote:
Hi,
Does anyone know if python has a hash function that one can pass a
size
to, to limit the returned hash value to a specific range?
I've got an array with ~520 color pairs, and I'd like to take an
arbitrary string of bytes, hash that, and use the hash as an index
into
that table to pull out the same color pair for the same bytes every
time.
As I understand it, Python's built-in hash function for the base types
is locked and optimizied to a table size of 2^32 or something like
that.
Err, wouldn't you normally just take that hash modulo your table size?
- Bert -
_______________________________________________
Sugar mailing list
[email protected]
http://mailman.laptop.org/mailman/listinfo/sugar