[Python-ideas] OrderedDict for kwargs and class statement namespace

Antoine Pitrou solipsis at pitrou.net
Thu Feb 28 16:48:10 CET 2013


Le Thu, 28 Feb 2013 09:30:50 -0600,
Don Spaulding <donspauldingii at gmail.com>
a écrit :
> 
> For an example of the "recommended" way to get the ordering of your
> class attributes:
> http://stackoverflow.com/questions/3288107/how-can-i-get-fields-in-an-original-order

This is already possible with the __prepare__ magic method.
http://docs.python.org/3.4/reference/datamodel.html#preparing-the-class-namespace

> It seems to me that the "right thing" for python to do when given an
> ordered list of key=value pairs in a function call or class
> definition, is to retain the order.  So what's an acceptable level of
> performance regression for the sake of doing things the "right way"
> here?

Or, rather, what is the benefit of doing things "the right way"? There
are incredibly few cases for relying on the order of key=value pairs in
function calls.

Regards

Antoine.





More information about the Python-ideas mailing list