On 15 May 2013 09:34, Steven D'Aprano <steve@pearwood.info> wrote:

I don't think that is a particularly good analogy. Stable sorting is
intuitively correct. Treating keyword args differently according to
their order is intuitively the wrong thing to do, at least most of the
time.

The argument *for* an ordered kwargs however is that same one that was used for Enums iterating in definition order by default - it's an ordering that can't be recovered once it's lost.

However, it's not a property that I think is absolutely necessary for kwargs and we shouldn't lose performance to gain that property, but there have been times when I would have liked it.

Barry created a new dict implementation a while back that as a side-effect retained insertion order so long as no keys were removed. That would be suitable IMO for kwargs as a guarantee - definition order so long as nothing has been removed. It was discussed and there was the suggestion to actively break this functionality in order to prevent people relying on it. I'm not sure what the end result of the discussion was off the top of my head.

Tim Delaney