On 15 September 2016 at 10:43, Raymond Hettinger
<raymond.hettin...@gmail.com> wrote:
> Something like this will reveal the true and massive improvement in iteration 
> speed:
>      $ ./python.exe -m timeit -s "d=dict.fromkeys(map(str,range(10**6)))" 
> "list(d)"

>py -3.5 -m timeit -s "d=dict.fromkeys(map(str,range(10**6)))" "list(d)"
10 loops, best of 3: 66.2 msec per loop
>py -3.6 -m timeit -s "d=dict.fromkeys(map(str,range(10**6)))" "list(d)"
10 loops, best of 3: 27.8 msec per loop

And for Victor:

>py -3.5 -m perf timeit -s "d=dict.fromkeys(map(str,range(10**6)))" "list(d)"
Median +- std dev: 65.7 ms +- 3.8 ms
>py -3.6 -m perf timeit -s "d=dict.fromkeys(map(str,range(10**6)))" "list(d)"
Median +- std dev: 27.9 ms +- 1.2 ms

Just as a side point, perf provided essentially identical results but
took 2 minutes as opposed to 8 seconds for timeit to do so. I
understand why perf is better, and I appreciate all the work Victor
did to create it, and analyze the results, but for getting a quick
impression of how a microbenchmark performs, I don't see timeit as
being *quite* as bad as Victor is claiming.

I will tend to use perf now that I have it installed, and now that I
know how to run a published timeit invocation using perf. It's a
really cool tool. But I certainly won't object to seeing people
publish timeit results (any more than I'd object to *any*

Python-Dev mailing list

Reply via email to