multiply each element of a list by a number

skip at skip at
Mon Dec 29 16:19:58 CET 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 -

More information about the Python-list mailing list