[Python-Dev] Review request: issue 27350, compact ordered dict (original) (raw)

INADA Naoki songofacandy at gmail.com
Wed Aug 10 12:52:58 EDT 2016


Thanks you for supporting.

BTW, my patch doesn't include OrderedDict speedup. (I'll try it when compact dict is merged.)

In case of Python 3, OrderedDict.move_to_end(key, last=False) can append item at front. So implementing OrderedDict based on compact dict is not so easy as OrderedDict = dict.

My idea is using compact_array (described in PyPy blog) as ring, not fixed capacity array. It means one of these two:

a. dict has one additional word and support ring internally. b. OrderedDict reimplements many APIs (iterating, resizing, etc...) to support ring.

I like (a) because it's easier to implement and maintain. But I don't know it can be in time for Python 3.6 beta.

On Thu, Aug 11, 2016 at 12:06 AM Maciej Fijalkowski <fijall at gmail.com> wrote:

Hello everyone.

I did do only a cursory look on that one, but I would like to reiterate that this gives huge benefits in general and we measured nice speedups on pypy (where all the dicts are ordered forever): * you can essentially kill OrderedDict or make it almost OrderedDict = dict (in pypy it's a simple dict subclass that has one or two extra things that OrderedDict has in the API) * there are nice speedups * the C version of OrderedDict can be killed * it saves memory, on 64bit by quite a bit (not everyone stores more than 4bln items in a dictionary) * it solves the problem of tests relying on order in dictionaries In short, it has no downsides On Tue, Aug 9, 2016 at 3:12 PM, INADA Naoki <songofacandy at gmail.com> wrote: > Hi, devs. > > I've implemented compact and ordered dictionary [1], which PyPy > implemented in 2015 [2]. > > Since it is my first large patch, I would like to have enough time for > review cycle by Python 3.6 beta1. > > Could someone review it? > > [1] http://bugs.python.org/issue27350 > [2] https://morepypy.blogspot.jp/2015/01/faster-more-memory-efficient-and-more.html > > -- > INADA Naoki <songofacandy at gmail.com> _> ________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/fijall%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20160810/5abdd094/attachment.html>



More information about the Python-Dev mailing list