Comment #16 on issue 1973 by [email protected]: hash(Integer) should return the int
http://code.google.com/p/sympy/issues/detail?id=1973

The hash theory is really simple: if hash(a) != hash(b), then a != b.
If hash(a) == hash(b), then we need to compare a and b directly to determine whether a == b or a != b.

As a valid (but useless) example of a hash function, consider hash(x) = 1 for all x.

From this it should be now obvious, that while we can choose any function for hash(x), in order to be efficient, we need to choose such a function that assigns a different value to different "x" for as many frequent "x" (in SymPy) as possible. It is clear that some "x" will collide. One can debate whether the choice of hash(-1) == hash(-2) is less effective than the choice hash(-1) != hash(-2) given that -1 and -2 are quite frequent numbers in SymPy. No doubt it is, but at the same time it is not a big deal.


So we just need to fix all hash() usage to use the above "theory".

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to