[Python-Dev] PEP 487: Simpler customization of class creation

Eric Snow ericsnowcurrently at gmail.com
Thu Jun 16 17:57:16 EDT 2016


On Thu, Jun 16, 2016 at 3:36 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> I don't think that's a side note, I think it's an important point (and
> relates to one of Nikita's questions as well): we have the option of
> carving out certain aspects of PEP 520 as CPython implementation
> details.
>
> In particular, the language level guarantee can be that "class
> statements set __definition_order__ by default, but may not do so when
> using a metaclass that returns a custom namespace from __prepare__",
> with the implementation detail that CPython does that by using
> collection.OrderedDict for the class namespace by default.
>
> An implementation like PyPy, with an inherently ordered standard dict
> implementation, can just rely on that rather than being obliged to
> switch to their full collections.OrderedDict type.

Excellent point from you both. :)  I'll rework PEP 520 accordingly (to
focus on __definition_order__).  At that point I expect the definition
order part of PEP 487 could be dropped (as redundant).

>
> However, I don't think we should leave the compile-time vs runtime
> definition order question as an implementation detail - I think we
> should be explicit that the definition order attribute captures the
> runtime definition order, with conditionals, loops and reassignment
> being handled accordingly.

Yeah, I'll make that clear.

We can discuss these changes in a separate thread once I've updated
PEP 520.  So let's focus back on the rest of PEP 487! :)

-eric


More information about the Python-Dev mailing list