[dictionary] how to get key by item
Roy Smith
roy at panix.com
Mon Dec 13 22:17:13 EST 2004
Skip Montanaro <skip at pobox.com> wrote:
> Roy> BTW, does Python really build the intermediate list and throw it
> Roy> away after using it to initialize the dictionary, or is it smart
> Roy> enough to know that it doesn't really need to build the whole list
> Roy> in memory?
>
> That's why I called .iteritems() in my example. It won't generate the
> entire list of tuples as .items() would.
I know it won't generate the list of items from the forward dict, but I
was thinking of the list generated by the list comprehension, passed as
the argument to the reverse dict constructor. That's the throw-away
list I was thinking of (see Tim Delaney's response to my post).
More information about the Python-list
mailing list