[Python-Dev] RE: [Python-checkins] python/dist/src/Lib weakref.py,1.19,1.20

Tim Peters tim_one@email.msn.com
Sun, 25 May 2003 13:17:22 -0400


[Raymond Hettinger]
> Arghh.  One more example always arises after going to bed.
>
> The original required only equality.  The new version requires
> equality, hashability, *and* weak referencability.

It always required (and still does) all three for __setitem__ and
__getitem__:  key equality and hashability are required for all dicts, and
*of course* key weak referencability is required for a weak-keyed dict:
that's why it's called a weak-keyed dict <0.5 wink>.

__delitem__ alone used a bizarre algorithm, and indeed one that broke other
normal dict invariants such as that

    del d[k]

always deletes the same (key, value) pair that

    d[k] = v

would have replaced.