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

Victor Stinner victor.stinner at gmail.com
Thu Sep 15 04:57:07 EDT 2016


2016-09-15 10:02 GMT+02:00 INADA Naoki <songofacandy at gmail.com>:
> In my environ:
>
> ~/local/python-master/bin/python3 -m timeit -s "d =
> dict.fromkeys(range(10**6))" 'list(d)'

Stooooop! Please stop using timeit, it's lying!

* You must not use the minimum but average or median
* You must run a microbenchmark in multiple processes to test
different randomized hash functions and different memory layouts

In short: you should use my perf module.
http://perf.readthedocs.io/en/latest/cli.html#timeit

The memory layout and the hash function have a major important on such
microbenchmark:
https://haypo.github.io/journey-to-stable-benchmark-average.html


> Both Python is built without neither `--with-optimizations` or `make
> profile-opt`.

That's bad :-) For most reliable benchmarks, it's better to use
LTO+PGO compilation.

Victor


More information about the Python-Dev mailing list