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

Serhiy Storchaka storchaka at gmail.com
Thu Sep 15 09:06:36 EDT 2016


On 15.09.16 12:43, Raymond Hettinger wrote:
>> On Sep 14, 2016, at 11:31 PM, 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
>
> A range of consecutive integers which have consecutive hash values is a really weak and non-representative basis for comparison.

With randomized integers the result is even worse.

$ ./python -m timeit -s "import random; a = list(range(10**6)); 
random.seed(0); random.shuffle(a); d = dict.fromkeys(a)" -- "list(d)"

Python 3.5: 10 loops, best of 3: 33.6 msec per loop
Python 3.6: 10 loops, best of 3: 166 msec per loop




More information about the Python-Dev mailing list