On Fri, 2006-01-27 at 13:20 -0500, Kent Johnson wrote: > It doesn't make much difference for small dictionaries. keys(), values() > and items() create new lists with the specified elements. iterkeys(), > itervalues() and iteritems() create iterators that return the specified > elements in sequence. So for the common case of iterating over dict > elements with a for loop, the 'iter' variants conserve memory and may be > faster (but always check!) because of the cost of creating the list. > > The iter variants are relatively new (since Python 2.2). I used to use > the older variants in examples here so I wouldn't have to explain the > difference :-) but ISTM that modern usage is heading to prefer the iter > versions and I am starting to use them myself. > > But I guess you will not notice any difference in performance until you > have dicts with many thousands of elements. > > Kent >
Hi Kent and Alan, Thanks to both for your response. Victor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor