INADA Naoki added the comment:
od.move_to_end() is slower too:
$ ./py-patched -m perf timeit --compare-to `pwd`/py-default -s 'from
collections import OrderedDict as odict; od =
odict.fromkeys("abcdefghijklmnopqrstuvwxyz")' -- 'od.move_to_end("a");
od.move_to_end("b")'
py-default: ..................... 196 ns +- 4 ns
py-patched: ..................... 227 ns +- 3 ns
Mean +- std dev: [py-default] 196 ns +- 4 ns -> [py-patched] 227 ns +- 3 ns:
1.16x slower (+16%)
$ ./py-patched -m perf timeit --compare-to `pwd`/py-default -s 'from
collections import OrderedDict as odict; od =
odict.fromkeys("abcdefghijklmnopqrstuvwxyz")' -- 'od.move_to_end("z")'
py-default: ..................... 74.7 ns +- 0.4 ns
py-patched: ..................... 91.1 ns +- 3.5 ns
Mean +- std dev: [py-default] 74.7 ns +- 0.4 ns -> [py-patched] 91.1 ns +- 3.5
ns: 1.22x slower (+22%)
$ ./py-patched -m perf timeit --compare-to `pwd`/py-default -s 'from
collections import OrderedDict as odict; od1 = odict.fromkeys(range(10000));
od2=odict.fromkeys(range(10000))' -- 'od1==od2'
py-default: ..................... 451 us +- 3 us
py-patched: ..................... 632 us +- 6 us
Mean +- std dev: [py-default] 451 us +- 3 us -> [py-patched] 632 us +- 6 us:
1.40x slower (+40%)
# pros
* 1000 less lines of code
* 50% less memory usage
* 15% faster creation
* 100% (2x) faster iteration
# cons
* Some inconsistency against pure Python implementation
* 20% slower move_to_end
* 40% slower comparison
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue31265>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com