[Python-Dev] For Python 3k, drop default/implicit hash, and comparison

Phillip J. Eby pje at telecommunity.com
Mon Nov 7 01:15:01 CET 2005

At 07:12 PM 11/6/2005 -0500, Phillip J. Eby wrote:
>At 01:29 PM 11/6/2005 -0800, Guido van Rossum wrote:
> >On 11/6/05, Phillip J. Eby <pje at telecommunity.com> wrote:
> > > At 12:58 PM 11/6/2005 -0800, Guido van Rossum wrote:
> > > >The main way this breaks down is when comparing objects of different
> > > >types. While most comparisons typically are defined in terms of
> > > >comparisons on simpler or contained objects, two objects of different
> > > >types that happen to have the same "key" shouldn't necessarily be
> > > >considered equal.
> > >
> > > When I use this pattern, I often just include the object's type in the
> > > key.  (I call it the 'hashcmp' value, but otherwise it's the same 
> pattern.)
> >
> >But how do you make that work with subclassing? (I'm guessing your
> >answer is that you don't. :-)
>By either changing the subclass __init__ to initialize it with a different
>hashcmp value, or by redefining the method that computes it.

Scratch that.  I realized 2 seconds after hitting "Send" that you meant the 
case where you want to compare instances with a common parent type.  And 
the answer is, I can't recall having needed to.  (Which is probably why it 
took me so long to realize what you meant.)

More information about the Python-Dev mailing list