Nick Coghlan wrote:
I have a different suggestion: an identity dictionary.
It ignores __hash__, __cmp__ and __eq__, and instead uses id() and is.
This might be useful in some special cases, though it's pretty easy to use a standard dict and explicitly use object ids as keys ( d[id(myobj)] = ... ).
It is, however, obviously not a replacement for the current implementation of dicts in the general case. Having keys, including sequence keys, which can compare by value is essential for the vast majority of (sane) dictionary use-cases.
To be honest, given how easy it is to key a current dict off of object id, I don't see much real value in creating a separate dict type that does it by default. But as long as it's an addition, rather than a change to existing behavior, then the only real problem with it is the standard "makes the language bigger".
Jeff Shannon Technician/Programmer Credit International
-- http://mail.python.org/mailman/listinfo/python-list