shouldn't list comprehension be faster than for loops?

Brian J Mingus Brian.Mingus at Colorado.EDU
Fri Dec 18 15:44:29 EST 2009


On Fri, Dec 18, 2009 at 11:55 AM, sturlamolden <sturlamolden at yahoo.no>wrote:

> On 17 Des, 18:37, 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.
> >
> > thoughts?
>
> Let me ask a retoric question:
>
> - How much do you really value 20 ms of CPU time?
>

If it takes 1 nanosecond to execute a single instruction then 20
milliseconds represents 20 million instructions. Therefore I value 20ms of
CPU time very much indeed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091218/137c15ce/attachment-0001.html>


More information about the Python-list mailing list