[Tutor] fast list traversal

Kent Johnson kent37 at tds.net
Thu Oct 30 21:01:45 CET 2008


On Thu, Oct 30, 2008 at 2:36 PM, Dinesh B Vadhia
<dineshbvadhia at hotmail.com> wrote:
> I need to process a large number (> 20,000) of long and variable length
> lists (> 5,000 elements) ie.
>
> for element in long_list:
>     <do something with element>        # the result of this operation is not
> a list
>
> The performance is reasonable but I wonder if there are faster Python
> methods?

A list comprehension might be faster. A specific code example would
help, optimizations are pretty specific to the job at hand.

Kent


More information about the Tutor mailing list