On 15.09.16 12:43, Raymond Hettinger wrote:
On Sep 14, 2016, at 11:31 PM, Serhiy Storchaka <storch...@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
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com