hashing an array - howto

Peter Otten __peter__ at web.de
Fri Sep 5 16:57:12 CEST 2008

Helmut Jarausch wrote:

> I need to hash arrays of integers (from the hash module).
> So, I have to derive from array and supply a __hash__ method.
> But how to hash an array (of fixed length, say 25)?
> What I need is a function which maps a tuple of 25 integers
> into 1 integer with good hashing properties.
> Does anybody know such a thing?

Have you tried this already?

def __hash__(self):
    return hash(self.tostring())


More information about the Python-list mailing list