[issue27576] An unexpected difference between dict and OrderedDict

Xiang Zhang report at bugs.python.org
Tue Jul 26 23:08:07 EDT 2016


Xiang Zhang added the comment:

I write a new version restoring the fast path for dict. It now uses PyDict_Next and seems to be much faster than the path using keys.

[cpython]$ ./python -m timeit -s 'from collections import OrderedDict; d = {"a":1,"c":2,"b":3,"d":4}' 'OrderedDict(d)'
1000000 loops, best of 3: 0.639 usec per loop
[cpython]$ ./python -m timeit -s 'from collections import OrderedDict; d = {"a":1,"c":2,"b":3,"d":4}' 'OrderedDict(d)'
1000000 loops, best of 3: 0.372 usec per loop

----------
Added file: http://bugs.python.org/file43902/odict_update_v3.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27576>
_______________________________________


More information about the Python-bugs-list mailing list