On Mon, Dec 10, 2012 at 11:29 PM, Tim Delaney <tim.dela...@aptare.com> wrote: > On 11 December 2012 05:01, Armin Rigo <ar...@tunes.org> wrote: >> >> Hi Philip, >> >> On Mon, Dec 10, 2012 at 5:16 PM, PJ Eby <p...@telecommunity.com> wrote: >> > On the other hand, this would also make a fast ordered dictionary >> > subclass possible, just by not using the free list for additions, >> > combined with periodic compaction before adds or after deletes. >> >> Technically, I could see Python switching to ordered dictionaries >> everywhere. Raymond's insight suddenly makes it easy for CPython and >> PyPy, and at least Jython could use the LinkedHashMap class (although >> this would need checking with Jython guys). I'd vaguely argue that >> dictionary orders are one of the few non-reproducible factors in a >> Python program, so it might be a good thing. But only vaguely --- >> maybe I got far too used to random orders over time... > > > Whilst I think Python should not move to ordered dictionaries everywhere, I > would say there is an argument (no pun intended) for making **kwargs a > dictionary that maintains insertion order *if there are no deletions*. It > sounds like we could get that for free with this implementation, although > from another post IronPython might not have something suitable. > Please, no. dict and kwargs should be unordered without any assumptions.
> I think there are real advantages to doing so - a trivial one being the > ability to easily initialise an ordered dictionary from another ordered > dictionary. > It can be done with adding short-circuit for OrderedDict class to accept another OrderedDict instance. > I could also see an argument for having this property for all dicts. There > are many dictionaries that are never deleted from (probably most dict > literals) and it would be nice to have an iteration order for them that > matched the source code. > > However if deletions occur all bets would be off. If you need to maintain > insertion order in the face of deletions, use an explicit ordereddict. > > Tim Delaney > > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/andrew.svetlov%40gmail.com > -- Thanks, Andrew Svetlov _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com