[Tutor] List comprehension question

Richard D. Moores rdmoores at gmail.com
Fri Nov 12 15:41:48 CET 2010

On Fri, Nov 12, 2010 at 05:15, David Hutto <smokefloat at gmail.com> wrote:
>>        repeatedly, returning a list of results. ...
>> I'm sorry, Steven, but I could you revise this code to use repeat=5
>> instead of the for loop? I can't see how to do it.
>>>> help(timeit.Timer
>  repeat(self, repeat=3, number=1000000)
>  |      Call timeit() a few times.
>  |
>  |      This is a convenience function that calls the timeit()
>  |      repeatedly, returning a list of results.  The first argument
>  |      specifies how many times to call timeit(), defaulting to 3;
>  |      the second argument specifies the timer argument, defaulting
>  |      to one million.
>  |
>  |      Note: it's tempting to calculate mean and standard deviation
>  |      from the result vector and report these.  However, this is not
>  |      very useful.  In a typical case, the lowest value gives a
>  |      lower bound for how fast your machine can run the given code
>  |      snippet; higher values in the result vector are typically not
>  |      caused by variability in Python's speed, but by other
>  |      processes interfering with your timing accuracy.  So the min()
>  |      of the result is probably the only number you should be
>  |      interested in.  After that, you should look at the entire
>  |      vector and apply common sense rather than statistics.

Look, I've already shown I know where the docs are, and have read
them. I don't understand how to use repeat() with my code. Wasn't that
clear to you?

More information about the Tutor mailing list