Comment #9 on issue 1973 by Vinzent.Steinberg: hash(Integer) should return
the int
http://code.google.com/p/sympy/issues/detail?id=1973
From the CPython source code:
/* Set of hash utility functions to help maintaining the invariant that
if a==b then hash(a)==hash(b)
All the utility functions (_Py_Hash*()) return "-1" to signify an error.
*/
and
tatic long
int_hash(PyIntObject *v)
{
/* XXX If this is changed, you also need to change the way
Python's long, float and complex types are hashed. */
long x = v -> ob_ival;
if (x == -1)
x = -2;
return x;
}
So we have to deal with hash collisions. I think they should mention the -1
special-case in the hash() docstring. It's imho a poor design choice that
-1 and -2 have the same hash.
--
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.