On Wed, Jul 8, 2009 at 21:37, Kent Johnson<ken...@tds.net> wrote: > On Wed, Jul 8, 2009 at 1:22 PM, Rich Lovely<roadier...@googlemail.com> wrote: > >> If you really want to speed up the search, you could turn the list of lists >> into a dict, using the first value in each sublist as a key: >> >> dct = dict((i[0], i[1:]) for i in lst) >> >> Then you can access it using the normal dictionary interface. >> dct["3991404"][3] > > I'm suspicious of this claim if there is only one lookup needed. You > iterate the whole list and incur the overhead of constructing a dict. > If there will be multiple lookups it may well be a win but as always > there is no substitute for measurement if you want to know what is > faster. > > Kent >
Hi Kent, No, I think the dict will be fine: I have to find every one that is in my original list. Many thanks to both you and Rich for all the help. I'll let you know how I get on. Cheers, Garry _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor