[Python-Dev] PEP 520: Preserving Class Attribute Definition Order (round 5)

Eric Snow ericsnowcurrently at gmail.com
Fri Jun 24 18:46:11 EDT 2016

On Fri, Jun 24, 2016 at 4:37 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> This version looks fine to me.


> The definition order question has been dropped from PEP 487, so this
> cross-reference doesn't really make sense any more :)

Ah, so much for my appeal to authority. <wink>

> I'd characterise this section at the language definition level as the
> default class definition namespace now being *permitted* to be an
> OrderedDict. For implementations where dict is ordered by default,
> there's no requirement to switch specifically to
> collections.OrderedDict.

Yeah, I'd meant to fix that.

> This paragraph is a little confusing, since "set
> ``__definition_order__`` manually" is ambiguous.
> "supply an explicit ``__definition_order__`` via the class namespace"
> might be clearer.


> I realised there's another important reason for doing it this way by
> default: it's *really easy* to write a "skip_dunder_names" filter that
> leaves out dunder names from an arbitrary interable of strings. It's
> flatout *impossible* to restore the dunder attribute order if the
> class definition process throws it away.

Yep.  That's why I felt fine with relaxing that.  I guess I didn't
actually put that in the PEP though. :)


More information about the Python-Dev mailing list