[Python-ideas] An identity dict

Benjamin Peterson benjamin at python.org
Tue Jun 1 02:44:41 CEST 2010


Raymond Hettinger <raymond.hettinger at ...> writes:
> Also, I haven't seen much of a discussion of use cases.

Here's a selection of use cases from PyPy's source (You can search for
"identity_dict" to see its use):

In a algorithm for breaking cycles in graphs:
http://codespeak.net/svn/pypy/trunk/pypy/tool/algo/graphlib.py

Keeping track of all the allocated objects in a model of a low level runtime:
http://codespeak.net/svn/pypy/trunk/pypy/rpython/lltypesystem/lltype.py

Tracing the source of a certain kind of type as our type checker annotate
RPython: http://codespeak.net/svn/pypy/trunk/pypy/annotation/bookkeeper.py

Traversing the blocks of a function's graph:
http://codespeak.net/svn/pypy/trunk/pypy/objspace/flow/model.py

Essentially these are places where defined equality should not matter.


I could also use it here:
http://code.activestate.com/recipes/577242-calling-c-level-finalizers-without-__del__/




More information about the Python-ideas mailing list