On Tue, Nov 7, 2017 at 9:32 AM, Antoine Pitrou <solip...@pitrou.net> wrote: > On Wed, 8 Nov 2017 00:01:04 +1000 > Nick Coghlan <ncogh...@gmail.com> wrote: > >> On 7 November 2017 at 23:48, Stefan Krah <ste...@bytereef.org> wrote: >> > >> > >> > This is just a reminder that the current dict is not an "OrderedDict": >> > >> >>>> from collections import OrderedDict >> >>>> OrderedDict(a=0, b=1) == OrderedDict(b=1, a=0) >> > False >> >>>> dict(a=0, b=1) == dict(b=1, a=0) >> > True >> > >> > The recent proposal was primarily about guaranteeing the insertion order of >> > dict literals. >> > >> > If further guarantees are proposed, perhaps it would be a good idea to >> > open a new thread and state what exactly is being proposed. >> >> "Insertion ordered until the first key removal" is the only guarantee >> that's being proposed. > > Is it? It seems to me that many arguments being made are only relevant > under the hypothesis that insertion is ordered even after the first key > removal. For example the user-friendliness argument, for I don't > think it's very user-friendly to have a guarantee that disappears > forever on the first __del__.
One common pattern that I see frequently is this: def foo(**kwargs): kwargs.pop('somekey', None) bar(**kwargs) With ordering breaking on first pop/delete we essentially have no guarantee about kwargs order, or at least it's very easy to break. It would make writing wrappers like this extremely tedious -- we are essentially forcing people to use OrderedDict to just pop an item from kwargs. Not to mention that this isn't cheap in terms of performance. Is there a *real* motivation for saying that pop/delete can break the order? Yury _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com