(original) (raw)
On 25 May 2015 07:26, "Guido van Rossum" <guido@python.org> wrote:
\>
\> On Sun, May 24, 2015 at 1:36 PM, Eric Snow <ericsnowcurrently@gmail.com> wrote:
>>
\>> My premise for storing the definition order on the class is that Guido was okay with using OrderedDict for cls.\_\_dict\_\_, which is a bigger change. Regardless, there are two reasons why it makes sense:
\>>
\>> \* If it makes sense to use OrderedDict by default for class definition then it makes sense to preserve the extra information OrderedDict provides.
\>> \* As I noted at the beginning of the thread, you could still preserve that info manually, but that makes it less convenient for library authors.
It occurs to me that even the basic change makes it possible to provide initialisation helpers that accept locals() from a currently running class definition and return a definition ordered list of fields (perhaps restricted to values of a certain type, such as database column definitions, or webform field definitions).
>> If you still think that's not enough justification then we can table \_\_definition\_order\_\_ for now.
\>
\>
\> Let's table it. It's hard to compare alternatives on a single dimension of "which is a bigger change".
Right, it isn't that I think \_\_definition\_order\_\_ is necessarily a bad idea, I just suspect it's redundant if we end up going ahead with \_\_init\_subclass\_\_ (which would allow a base class to opt in to preserving the definition order, either of all fields or selected ones), and the latter change is definitely out of scope for 3.5 at this point.
There are also other open questions, like whether or not dir() should respect the order when reporting attribute names, or if dict\_proxy should respect the order when iterating.
Regards,
Nick.
>
\> --
\> --Guido van Rossum (python.org/\~guido)