7 Aug
2002
7 Aug
'02
4:09 a.m.
[Tim]
The object's id() (address) is the key. Else only hashable objects could be pickled.
[Greg Ewing]
Hmmm, I see.
It occurs to me that what you really want here is a special kind of dictionary that uses "is" instead of "==" to compare key values.
Possibly. The *effect* of that could be gotten via a wrapper object, like class KeyViaId: def __init__(self, obj): self.obj = obj def __hash__(self): return hash(id(self.obj)) def __eq__(self, other): return self.obj is other.obj but if Martin is worried about two-tuple sizes, he's not going to fall in love with that.
Or is that what was meant by an "identity dictionary"?
Guido asked, but if Martin answered that question I haven't seen it yet.