How do I get a reference to a KEY value of a dictionary?

Andy C ayc8NOSPAM at cornell.edu
Sun Aug 3 04:51:40 EDT 2003


Thanks, looks interesting... but it actually doesn't really address the
question I was asking.  It doesn't matter since I think the intern solution
is fine for me.  But if I'm not mistaken, your solution still stores the
node names in the values of the dictionary (via the Node objects).  So in
effect you do still have a dictionary of the form { 'node1name':
('node1name', other node1 data), 'node2name': ('node2name', other node2
data)).  It doesn't seem as silly when you have a real node object, though.
In my application the nodes are really just strings; I don't need anything
else.

Andy

"Bengt Richter" <bokr at oz.net> wrote in message
news:bgho7i$790$0 at 216.39.172.122...
> On Sat, 02 Aug 2003 23:34:20 GMT, "Andy C" <ayc8NOSPAM at cornell.edu> wrote:
>
> >> Google("intern-like memory saver").
> >
> >Well, that seems very sensical, so how come it hasn't made it into the
> >language?  And what's wrong with intern?  (Though intern only works on
> >strings, not for immutable objects in general.  I believe someone was
asking
> >a pretty much identical question here, and someone replied with the
> >'memoize' pattern).
> >
> >Can this be done without C, now that you can subclass the built-in
> >dictionary?
> >
> For a subclass of dict that may be of interest, see my post in this thread
> timestamped less than 2 minutes before this post of yours ;-)
>
> Regards,
> Bengt Richter






More information about the Python-list mailing list