[Python-Dev] Ordering keyword dicts
Guido van Rossum
guido at python.org
Sun May 19 07:47:35 CEST 2013
On Sat, May 18, 2013 at 10:27 PM, Raymond Hettinger
<raymond.hettinger at gmail.com> wrote:
> BTW, I'm +1 on the idea for ordering keyword-args. It makes
> it easier to debug if the arguments show-up in the order they
> were created. AFAICT, no purpose is served by scrambling them
> (which is exacerbated by the new randomized hashing security feature).
I'm slow at warming up to the idea. My main concern is speed -- since
most code doesn't need it and function calls are already slow (and
obviously very common :-) it would be a shame if this slowed down
function calls that don't need it noticeably.
An observation is that it's only necessary to preserve order if the
function definition uses **kwds. AFAIK we currently don't know if this
is the case when the call is made though, but perhaps the information
could be made available to the call site somehow.
There are also many special cases to consider; e.g. using **kwds in
the call where kwds is an unordered dict, or calls from C, or calls to
But maybe someone considers this a challenge and comes up with a
patch? The benefits to *some* use cases would be obvious.
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev