[Python-3000] object.__hash__()
Steven Bethard
steven.bethard at gmail.com
Thu Jul 27 18:23:38 CEST 2006
On 7/27/06, Guido van Rossum <guido at python.org> wrote:
> On 7/27/06, Steven Bethard <steven.bethard at gmail.com> wrote:
> > If I understand the problem right, the reason for not wanting to
> > remove __hash__ from object is that it's often convenient to have a
> > dict or set where objects are compared by id() instead of by value.
>
> No, not at all. This is for objects whose __eq__ is also the default
[snip]
So what's the problem with losing the default hash then? I thought
the default hash was basically just hash(id(obj))::
>>> class C(object):
... pass
...
>>> hash(C)
13565672
>>> hash(id(C))
13565672
>>> c = C()
>>> hash(c)
15130928
>>> hash(id(c))
15130928
If object.__hash__() disappeared, the hash(obj) versions would fail,
but the same results seem to be available as hash(id(obj)).
Steve
--
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
More information about the Python-3000
mailing list