hashability question

Manuel M. Garcia mgarcia at cole-switches.com
Fri Oct 11 14:20:29 EDT 2002


On Fri, 11 Oct 2002 16:37:23 +0100, Gonçalo Rodrigues
<op73418 at mail.telepac.pt> wrote:

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

This is the perfect way to do it.  You are relying on the built in
hash() function, and because it is used in every Python dictionary, it
is optimized to be fast with no trivial pathological behavior.



More information about the Python-list mailing list