Python: What's a correct and good way to implement __hash__()?

Posted by random-name on Stack Overflow See other posts from Stack Overflow or by random-name
Published on 2010-05-25T22:56:46Z Indexed on 2010/05/25 23:01 UTC
Read the original article Hit count: 143

Filed under:
|
|
|

What's a correct and good way to implement hash()?

I am talking about the function that returns a hashcode that is then used to insert objects into hashtables aka dictionaries.

As hash() returns an integer and is used for "binning" objects into hashtables I assume that the values of the returned integer should be uniformly distributed for common data (to minimize collisions). What's a good practice to get such values? Are collisions a problem? In my case I have a small class which acts as a container class holding some ints, some floats and a string.

© Stack Overflow or respective owner

Related posts about python

Related posts about hashtable