dict: retrieve the original key by key


C

Christoph Groth

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
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top