Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5409 > unrolled thread

dict: retrieve the original key by key

Started byChristoph Groth <cwg@falma.de>
First post2011-05-15 10:28 +0200
Last post2011-05-15 10:28 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  dict: retrieve the original key by key Christoph Groth <cwg@falma.de> - 2011-05-15 10:28 +0200

#5409 — dict: retrieve the original key by key

FromChristoph Groth <cwg@falma.de>
Date2011-05-15 10:28 +0200
Subjectdict: retrieve the original key by key
Message-ID<mailman.1579.1305448157.9059.python-list@python.org>
Dear python experts,

I use a huge python dictionary where the values are lists of that
dictionary's keys (yes, a graph).  Each key is thus referenced several
times.

As the keys are rather large objects, I would like to save memory by
re-using key objects wherever possible, instead of having several equal
objects in memory.

There does not seem to be a way to retrieve the original key from a
python dictionary.  Is there a technical reason for this?  (Other than
that such functionality was not considered to be useful enough.)

What I will probably do now is store (key, real_value) as values in my
dictionary.  Is there a better solution?

thanks,
Christoph

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web