shouldn't list comprehension be faster than for loops?
pavlovevidence at gmail.com
Fri Dec 18 19:50:00 CET 2009
On Dec 17, 9:37 am, Carlos Grohmann <carlos.grohm... at gmail.com> wrote:
> Tenting the time spent by each approach (using time.clock()), with a
> file with about 100,000 entries, I get 0.03s for the loop and 0.05s
> for the listcomp.
You shouldn't trust your intuition in things like this. Some features
were added to Python to make writing easier, not to make it run
faster. This time your intuition was correct. Next time, who knows?
More information about the Python-list