[Python-Dev] Weird use of hash() -- will this work?

Tim Peters tim.one@home.com
Thu, 18 Jan 2001 17:58:22 -0500

[Tim whined]
> BTW, why doesn't hash([]) blow up in 2.1a1?  In 2.0 it raised
>     TypeError: unhashable type
> Did someone change this deliberately?

Answer:  it's an unintended consequence of the rich-comparison changes.
Guido knows how to fix it and probably <wink> will.  The list type grew a
tp_richcompare slot but lost its non-NULL tp_compare pointer.  PyObject_Hash
wasn't changed accordingly (it now believes lists support neither direct
hashing nor comparison, so does them a favor and hashes their memory
addresses).  Something trickier is probably going wrong elsewhere too, but I
won't try to remember what that is unless Guido gets hit by a bus tonight.

    y'rs  - tim