[Python-ideas] Proto-PEP: Preserving the order of **kwargs in a function.
Alexander Belopolsky
alexander.belopolsky at gmail.com
Fri Apr 11 14:07:04 CEST 2014
On Fri, Apr 11, 2014 at 7:49 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> > Not really. It was just a silly example for conciseness. I don't care
> how
> > you build up the OrderedDict, and there are several order-preserving
> ways to
> > do that. I'm not sure it's a good idea to change *all of Python* just
> to make
> > the OD constructor nicer.
>
> It's not "all of Python" - it's only functions that accept **kwargs. And
> when your code is speed critical, doing that's already a bad idea.
>
And it is not just about OrderedDict. There are many other examples where
it is helpful to be able to supply arbitrary keyword arguments and have the
order preserved. For example, when building a memory view to a C struct, a
nice interface would be struct_view(foo=int, bar=float). Another example
is constructing tables. One may want to supply column info in keyword
arguments named as columns.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140411/5ea8748b/attachment.html>
More information about the Python-ideas
mailing list