[Python-ideas] A way out of Meta-hell (was: A (meta)class algebra)
Nick Coghlan
ncoghlan at gmail.com
Sun Feb 15 11:08:18 CET 2015
On 14 February 2015 at 20:23, Petr Viktorin <encukou at gmail.com> wrote:
> On Sat, Feb 14, 2015 at 10:34 AM, Martin Teichmann
> <lkb.teichmann at gmail.com> wrote:
>
>> I think that implementing PEP 422 as part of the language only
>> makes sense if we once would be able to drop metaclasses
>> altogether. I thought about adding a __new_class__ to PEP 422
>> that would simulate the __new__ in metaclasses, thinking that
>> this is the only way metaclasses are used.
>
> Well, if you want Python to drop metaclasses, the way starts with PEP
> 422. You have to introduce the alternative first, and then wait a
> *really* long time until you drop a feature.
> I think __new_class__ can be added after PEP 422 is in, if it turns
> out to be necessary.
There's nothing wrong with metaclasses per se - they work fine for
implementing things like abc.ABC, enum.Enum, SQL ORMs and more.
There's just a significant subset of their current use cases that
doesn't need their full power and could benefit from having a simpler
alternative mechanism available.
PEP 422 aims to carve out that subset and provide a simpler way of
doing the same thing. A pure Python equivalent has existed in Zope for
over a decade (which is referenced from the PEP after someone pointed
it out in one of the earlier review rounds).
If someone had the time to update the PEP to address the issues raised
in the last round of reviews, I'd be happy to add a third co-author :)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list