[Python-Dev] Review of PEP 520: Ordered Class Definition Namespace
ncoghlan at gmail.com
Tue Jun 21 17:21:21 EDT 2016
On 20 June 2016 at 19:11, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> FWIW, regarding repercussions, I do not expect any other potential
> future feature will subsume the functionality of PEP 520. The closest
> thing would be if cls.__dict__ became ordered. However, that would
> intersect with __definition_order__ only at first. Furthermore,
> cls.__dict__ would only ever be able to make vague promises about any
> relationship with the definiton order. The point of
> __definiton_order__ is to provide the one obvious place to get a
> specific bit of information about a class.
It occurs to me that a settable __definition_order__ provides a
benefit that an ordered tp_dict doesn't: to get the "right" definition
order in something like Cython or dynamic type creation, you don't
need to carefully craft the order in which attributes are defined, you
just need to set __definition_order__ appropriately.
It also means that the "include dunder-attributes or not" decision is
easy to override, regardless of what we set as the default.
By contrast, if the *only* ordering information is
cls.__dict__.keys(), then there's no way for a type implementor to
hide implementation details.
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev