[Python-Dev] Review of PEP 520: Ordered Class Definition Namespace (original) (raw)

Nick Coghlan 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 definitionorder 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 definitonorder 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.

Cheers, Nick.

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



More information about the Python-Dev mailing list