This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author methane
Recipients methane
Date 2017-08-23.10:24:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1503483859.09.0.0369181186057.issue31265@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2017-08-23 10:24:19methanesetrecipients: + methane
2017-08-23 10:24:19methanesetmessageid: <1503483859.09.0.0369181186057.issue31265@psf.upfronthosting.co.za>
2017-08-23 10:24:19methanelinkissue31265 messages
2017-08-23 10:24:18methanecreate