[Python-Dev] PEP: Ordered Class Definition Namespace

Nick Coghlan ncoghlan at gmail.com
Tue Jun 7 17:34:37 EDT 2016

On 7 June 2016 at 14:20, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> On Tue, Jun 7, 2016 at 12:30 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> The main alternative would be to make __definition_order__ writable,
>> so the default behaviour would be for it to reflect the original class
>> body, but decorators would be free to update it to reflect their
>> changes, as well as to make other modifications (e.g. stripping out
>> all callables from the list).
> I think both of those make __definition_order__ more complicated and
> less useful.  As the PEP stands, folks can be confident in what
> __definition_order__ represents.  What would you consider to be the
> benefit of a mutable (or replaceable) __definition_order__ that
> outweighs the benefit of a simpler definition of what's in it.

Mainly the fact that class decorators and metaclasses can't hide the
difference between "attributes defined in the class body" and
"attributes injected by a decorator or metaclass". I don't have a
concrete use case for that, it just bothers me on general principles
when we have things the interpreter can do that can't readily be
emulated in Python code.

However, if it proves to be a hassle in practice, making it writable
can be done later based on specific use cases, so I don't mind if the
PEP stays as it is on that front.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list