On 7/29/08, Chris Rebert <[EMAIL PROTECTED]> wrote:
> If the latter, than you shouldn't implement __hash__ because, as the
> docs you quote say, Bad Things (tm) will happen if someone puts your
> object into a dict and then mutates it.
Not quite.
> So really it comes down to answering the que
Greg Ewing wrote:
Nick Coghlan wrote:
Objects which compare equal must also end up in the same hash bucket
in order for dictionaries to work correctly.
And, if its equality with another object can change during
its lifetime, it will never work properly in a dictionary.
So in that case you sho
Nick Coghlan wrote:
Objects which compare equal must also end up in the same hash bucket in
order for dictionaries to work correctly.
And, if its equality with another object can change during
its lifetime, it will never work properly in a dictionary.
So in that case you should leave __hash__
Charles Hixson wrote:
.../Python-3.0b2/Python-3.0b2/Doc/build/html/reference/datamodel.html#object.__hash__
"""If a class defines mutable objects and implements a __cmp__() or __eq__()
method, it should not implement __hash__(), since the dictionary
implementation requires that a key’s hash va
Your question isn't really Python-3000-specific, and belongs more on
the comp.lang.python list.
That said, whether it's right for your object really depends on how
you're defining equality for it. Are you defining equality as merely
identity (i.e. are they pointers to the same spot in memory) or d