[Python-3000] object.__hash__()

Guido van Rossum guido at python.org
Thu Jul 27 18:14:47 CEST 2006


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
(which happens to compare by id). Such objects aren't considered to
have a "value" in the sense that a list or dict or int has a value,
because whatever attributes they have aren't considered for
comparison. Each instance of such classes is a unique value.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list