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

Eric Snow ericsnowcurrently at gmail.com
Sat Jun 11 23:01:33 EDT 2016


On Sat, Jun 11, 2016 at 7:51 PM, Émanuel Barry <vgr255 at live.ca> wrote:

From: Eric Snow 1. if _definitionorder_ is defined in the class body then it must be a tuple of identifiers or None; any other value will result in TypeError Why not just any arbitrary iterable, which get converted to a tuple at runtime?

An arbitrary iterable does not necessarily infer a definition order. For example, dict is an iterable but the order is undefined. Also, I'd rather favor simplicity for this (most likely) uncommon corner case of manually setting definition_order, particularly at the start. If it proves to be a problematic restriction in the future we can loosen it.

slots allows any arbitrary iterable:

Yes, but slots is not order-sensitive.

is already complete by the time ``definitionorder`` is set, the_ Typo: missing leading underscores in definitionorder

I'll fix that.

Compatibility =============

This PEP does not break backward compatibility, except in the case that someone relies strictly on dict as the class definition namespace. This shouldn't be a problem. Perhaps add a mention that isinstance(namespace, dict) will still be true, so users don't get unnecessarily confused.

Good point.

.dict as OrderedDict ------------------------------- looks weird to me. I tend to use cls (although klass isn't uncommon). C might also not be a bad choice.

Yes, that is better.

-eric



More information about the Python-Dev mailing list