[Python-ideas] An identity dict
Jack Diederich
jackdied at gmail.com
Tue Jun 1 01:31:06 CEST 2010
On Mon, May 31, 2010 at 2:05 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> current vote: -.3
> I am also not yet convinced, but perhaps could be, that either type, with or
> without generalization should be in the stdlib. Instances of user class
> without custom equality are already compared by identity. The use cases for
> keying immutables by identify is pretty sparse. That pretty much leave
> mutables with custom equality (by value rather than identity).
I'm -1 on the idea without a strong use case. I vaguely recall
implementing one of these before but I think I was using it as a hacky
weakrefdict. Looking in my libmisc.py for dict-alikes I see an
OrderedDict (obsoleted), a ForgivingDict (obsoleted by defaultdict), a
ProxyDict, and a DecorateDict. The ProxyDict can push/pop dicts and
does lookups across all of them, most recent first, and performs sets
in the most recent. The DecorateDict calls a function on the value
before returning it. Django has classes with almost the exact same
code (not contributed by me).
Django:
http://code.djangoproject.com/svn/django/trunk/django/utils/datastructures.py
Me:
http://bazaar.launchpad.net/~odbrazen/leanlyn/trunk/annotate/head:/libmisc.py
-Jack
More information about the Python-ideas
mailing list