<p dir="ltr">On Apr 5, 2014 3:38 PM, "Nick Coghlan" <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
> In the context of serialisation, one key lesson we have learned is that arbitrary ordering is a problem when you want to minimise spurious diffs, and sorting isn't a simple solution.</p>
<p dir="ltr">Good point.</p>
<p dir="ltr">><br>
> Tools like doctest don't tolerate spurious diffs at all, but are often amenable to a sorting based answer.<br>
[snip]<br>
> These *can* all be done today, but *not* by using keyword arguments. In my view, the problem to be addressed is that keyword arguments *look* like they should work for these cases, because they have a definite order in the source code. The only reason they don't work is because the interpreter throws that ordering information away.<br>
><br>
> It's a textbook case of a language feature becoming an attractive nuisance in some circumstances: the simple and obvious solution for the above use cases *doesn't actually work* for reasons that aren't obviously clear if you don't have a firm grasp of Python's admittedly complicated argument handling.</p>
<p dir="ltr">That's a great way of putting it.</p>
<p dir="ltr">><br>
> The simplest way out that I can see? Just make it work, even if that means also preserving the order of arbitrary keyword arguments in cases that *dont* need it.</p>
<p dir="ltr">So you're advocating simply using OrderedDict for kwargs? Ultimately that's my preference too. The other options are attempts at addressing concerns that have come up, particularly Guido's.</p>
<p dir="ltr">Also, "just make it work" must include not having a meaningful impact on function call performance. :) That was the big objection to the original proposal(s) to just switch kwargs to OrderedDict.</p>
<p dir="ltr">><br>
> Deciding whether or not to provide a way to opt in to dropping the order info for speed and memory reasons then becomes a separate optimisation discussion *after* the current usability trap has been addressed.</p>
<p dir="ltr">Sort of. The PEP certainly needs to address this point one way or the other. Unless Guido relaxes his objections, that is. :) Regardless, once I have a draft PEP out the next step will be to implement the OrderedDict swap and see how things look performance-wise. It may turn out that the impact is marginal, at which point the PEP won't have to say much.</p>
<p dir="ltr">-eric</p>