multiply each element of a list by a number

skip at pobox.com skip at pobox.com
Mon Dec 29 10:19:58 EST 2008


    Colin> That's interesting but that's not the 
    Colin> way timeit is documented for Python 2.5:

    Colin> timeit( [number=1000000])

That's how it works when invoked as a main program using -m.

    Colin> In spite of the fact that your own data doesn't support the
    Colin> assertion?

    Colin> I would have expected numpy to be the clear winner for len >
    Colin> 1,500.

It is.  In fact, it's the clear winner well below that.  Below I have
reorganized the timeit output so the units are the same for all runs
(*microseconds* per loop):

     length     numpy           pure python
          1      11.7               0.698
         10      11.7               2.94
        100      12.1              24.4
       1000      15               224
      10000      41              2170
     100000     301             22200

-- 
Skip Montanaro - skip at pobox.com - http://smontanaro.dyndns.org/



More information about the Python-list mailing list