dictionary keys, __hash__, __cmp__
mwh at python.net
Wed Nov 5 14:37:52 CET 2003
Michael Hudson <mwh at python.net> writes:
> Jan-Erik Meyer-Lütgens <python at meyer-luetgens.de> writes:
> > -- I can ignore the 2nd statement, if I am aware of
> > the fact that: if objects are equal it dosn't mean that
> > they are the same key.
> Um, I don't understand you, but I think the answer is "no".
> If you ever have a situation where hash(a) != hash(b) but a == b then
> you are very much breaking the rules.
Having thought about it a bit more, I think the way you're doing
things *is* actually safe given a platform where sizeof(int) ==
sizeof(PyObject*) and the current implementation, but sheesh, I
wouldn't want to rely on it.
In short, just business as usual in the wacky world of floating
point <wink>. -- Tim Peters, comp.lang.python
More information about the Python-list