[Python-ideas] An identity dict
Michael
fuzzyman at gmail.com
Sun May 30 11:29:35 CEST 2010
+1 - this has been useful to me in other languages.
(apologies for top-post, sent from phone.)
Michael Foord
--
http://www.ironpythoninaction.com
On 30 May 2010, at 04:27, Benjamin Peterson <benjamin at python.org> wrote:
> In the spirit of collections.OrderedDict and
> collections.defaultdict, I'd like
> to propose collections.identitydict. It would function just like a
> normal
> dictionary, but ignore hash values and comparison operators and
> merely lookup
> keys based on the key's id().
>
> This dict is very useful for keep track of objects that should not
> be compared
> by normal comparison methods. For example, I would use an
> identitydict to hold
> weak references that would otherwise fallback to their referant
> object's hash.
>
> An advantage of formalizing this in collections would be to enable
> other Python
> implementations like PyPy, where id() is expensive, to provide an
> optimized
> identitydict.
>
> Regards,
> Benjamin
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
More information about the Python-ideas
mailing list