[sugar] python hash function limited to specific table size?
bert at freudenbergs.de
Thu Mar 15 08:31:39 EDT 2007
On Mar 15, 2007, at 13:09 , Dan Williams wrote:
> Does anyone know if python has a hash function that one can pass a
> 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
> that table to pull out the same color pair for the same bytes every
> 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
Err, wouldn't you normally just take that hash modulo your table size?
- Bert -
More information about the Sugar