[Python-Dev] Python 3.6 dict becomes compact and gets a private version; and keywords become ordered (original) (raw)

Paul Moore p.f.moore at gmail.com
Thu Sep 15 07:27:51 EDT 2016


On 15 September 2016 at 10:43, Raymond Hettinger <raymond.hettinger at 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 mirobenchmark).

Paul



More information about the Python-Dev mailing list