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

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.

\o/

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.

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 _definitionorder_ manually" is ambiguous.

"supply an explicit _definitionorder_ via the class namespace" might be clearer.

ack

I realised there's another important reason for doing it this way by default: it's really easy to write a "skipdundernames" 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. :)

-eric



More information about the Python-Dev mailing list