dict: retrieve the original key by key

Discussion in 'Python' started by Christoph Groth, May 15, 2011.

  1. 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
    Christoph Groth, May 15, 2011
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Skip Montanaro
    Replies:
    0
    Views:
    412
    Skip Montanaro
    Aug 15, 2003
  2. Alexander Kozlovsky

    dict!ident as equivalent of dict["ident"]

    Alexander Kozlovsky, May 21, 2006, in forum: Python
    Replies:
    5
    Views:
    357
    Alexander Kozlovsky
    May 22, 2006
  3. Albert van der Horst

    dict's as dict's key.

    Albert van der Horst, Jan 13, 2010, in forum: Python
    Replies:
    5
    Views:
    255
    Lie Ryan
    Jan 17, 2010
  4. Christoph Groth

    Re: dict: retrieve the original key by key

    Christoph Groth, May 15, 2011, in forum: Python
    Replies:
    5
    Views:
    289
    Ian Kelly
    May 16, 2011
  5. Victor Hooi
    Replies:
    1
    Views:
    107
    Victor Hooi
    Oct 29, 2013
Loading...

Share This Page