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


Groups > comp.lang.python > #5409

dict: retrieve the original key by key

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'memory.': 0.05; 'dictionary': 0.07; 'python': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'referenced': 0.09; '(key,': 0.16; '(other': 0.16; 'solution?': 0.16; 'subject:key': 0.16; 'thanks,': 0.17; 'this?': 0.18; 'values': 0.23; 'keys': 0.23; 'objects,': 0.23; 'objects': 0.24; 'thus': 0.24; 'memory': 0.24; 'possible,': 0.25; 'instead': 0.26; 'times.': 0.26; 'lists': 0.28; 'technical': 0.29; 'probably': 0.30; 'seem': 0.30; 'does': 0.31; 'equal': 0.31; 'to:addr:python-list': 0.32; 'store': 0.32; 'several': 0.33; 'header:X-Complaints-To:1': 0.34; 'there': 0.35; 'header:User- Agent:1': 0.35; 'rather': 0.36; 'considered': 0.36; 'charset:us- ascii': 0.36; 'useful': 0.37; 'received:org': 0.38; 'received:82': 0.38; 'to:addr:python.org': 0.39; 'where': 0.39; 'header:Mime- Version:1': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'retrieve': 0.60; 'huge': 0.62; 'dear': 0.64; 'subject:original': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Christoph Groth <cwg@falma.de>
Subject dict: retrieve the original key by key
Date Sun, 15 May 2011 10:28:53 +0200
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host dra38-5-82-246-248-175.fbx.proxad.net
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)
Cancel-Lock sha1:6nHRf9lXQerCKNBilfcosJQ78Ck=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1579.1305448157.9059.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 82.94.164.166
X-Trace 1305448157 news.xs4all.nl 65870 [::ffff:82.94.164.166]:36896
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5409

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web