List comprehensions performance

Remco Boerma remco at tomaatnet.nl
Thu Sep 30 05:10:45 EDT 2004


Yup, use the standard timeit module for testing.
Made for these purposes. .
http://epydoc.sourceforge.net/stdlib/public/timeit-module.html

Cheers!
Remco

Skip Montanaro wrote:
>     Neuruss> What I'd like to know is if using list comprehensions would
>     Neuruss> give me a performance advantage over traditional for loops or
>     Neuruss> not.
> 
> You can always run tests to see. <wink>  There is some data dependency so it
> makes sense to test map, listcomps and for loops using data that's typical
> of the application you intend to use them in.
> 
> Skip



More information about the Python-list mailing list