[New-bugs-announce] [issue31265] Remove doubly-linked list from C OrderedDict
INADA Naoki
report at bugs.python.org
Wed Aug 23 06:24:19 EDT 2017
New submission from INADA Naoki:
Since dict preserves insertion order, doubly linked list in OrderedDict
can be removed.
There is small performance improvement for odict creation:
$ curl https://api.github.com/orgs/python/repos > repos.json
$ ./py-patched -m perf timeit --compare-to `pwd`/py-default -s 'from collections import OrderedDict as od; import json; data=open("repos.json").read()' -- 'json.loads(data, object_pairs_hook=od)'
py-default: ..................... 1.53 ms +- 0.01 ms
py-patched: ..................... 1.30 ms +- 0.01 ms
Mean +- std dev: [py-default] 1.53 ms +- 0.01 ms -> [py-patched] 1.30 ms +- 0.01 ms: 1.18x faster (-15%)
And more memory efficient:
$ ./py-default -c 'from collections import OrderedDict; import sys; print(sys.getsizeof(OrderedDict.fromkeys(range(1000))))'
85416
$ ./py-patched -c 'from collections import OrderedDict; import sys; print(sys.getsizeof(OrderedDict.fromkeys(range(1000))))'
36992
But most important benefit is smaller code. It make easy to maintain.
----------
components: Interpreter Core
messages: 300748
nosy: inada.naoki
priority: normal
severity: normal
status: open
title: Remove doubly-linked list from C OrderedDict
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31265>
_______________________________________
More information about the New-bugs-announce
mailing list