[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 04:11:14 EDT 2016


On 15 September 2016 at 07:31, Serhiy Storchaka <storchaka at gmail.com> wrote:
> Note that this is made at the expense of the 20% slowing down an iteration.
>
> $ ./python -m timeit -s "d = dict.fromkeys(range(10**6))" -- "list(d)"
> Python 3.5: 66.1 msec per loop
> Python 3.6: 82.5 msec per loop

On my Windows 7 PC with 3.5.2 and 3.6.0b1 installed from the standard
python.org builds:

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

So 3.6 is faster for me.

Paul


More information about the Python-Dev mailing list