On 7/26/2018 2:15 AM, Raymond Hettinger wrote: >On Jul 25, 2018, at 8:23 PM, INADA Naoki <songofacandy at gmail.com> wrote: >> On Thu, Jul 26, 2018 at 12:04 PM Zhao Lee <redstone-cold at 163.com> wrote: >>> Since Python 3.7,dicts remember the order that items were inserted, so any plans to combine collections.OrderedDict with dict? >>> https://docs.python.org/3/library/collections.html?#collections.OrderedDict >>> https://docs.python.org/3/library/stdtypes.html#dict >> No. There are some major difference. >> * d1 == d2 ignores order / od1 == od2 compares order >> * OrderedDict has move_to_end() method. >> * OrderedDict.pop() takes `last=True` keyword. > In addition to the API differences noted by Naoki, there are also implementation differences. The regular dict implements a low-cost solution for common cases. The OrderedDict has a more complex scheme that can handle frequent rearrangements (move_to_end operations) without touching, resizing, or reordering the underlying dictionary. Roughly speaking, regular dicts emphasize fast, space-efficient core dictionary operations over ordering requirements while OrderedDicts prioritize ordering operations over other considerations. > > That said, now that regular dicts are ordered by default, the need for collections.OrderedDict() should diminish quite a bit. Mostly, I think people will ignore OrderedDict unless their application heavily exercises move to end operations. On python-idea, Miro Hrončok asked today whether we can change the OrderedDict repr from, for instance, OrderedDict([('a', '1'), ('b', '2')]) # to OrderedDict({'a': '1', 'b': '2'}) I am not sure what our repr change policy is, as there is a back-compatibility issue but I remember there being changes. -- Terry Jan Reedy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4