hashability question

Gonçalo Rodrigues op73418 at mail.telepac.pt
Fri Oct 11 11:37:23 EDT 2002


Hi,

I have a class whose instances are timestamped at their moment of
creation. Their equality is naturally defined. I want to make them
hashable so the first obvious thing to do was

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

where the __time attribute holds the timestamp. I don't know the first
thing about good criteria for hashing functions so I am asking the more
knowledgeable people, is this a good hashing function, or does it suffer
from some terrible handicap?

Thanks in advance,
Gonçalo Rodrigues



More information about the Python-list mailing list