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

Paul Moore p.f.moore at gmail.com
Thu Sep 15 05:26:05 EDT 2016


On 15 September 2016 at 09:57, Victor Stinner <victor.stinner at gmail.com> wrote:
> 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

Made essentially no difference to the results I posted:

>py -3.5 -m perf timeit -s "d = dict.fromkeys(range(10**6))" -- "list(d)"
....................
Median +- std dev: 21.4 ms +- 0.7 ms
>py -3.6 -m perf timeit -s "d = dict.fromkeys(range(10**6))" -- "list(d)"
....................
Median +- std dev: 20.0 ms +- 1.1 ms

3.6 remains faster, by very little (barely one standard deviation).

I would consider that the same result as timeit (to the level that
it's reasonable to assign any meaning to a microbenchmark).

Paul


More information about the Python-Dev mailing list