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

Martin Teichmann lkb.teichmann at gmail.com
Sun Jul 3 18:27:20 EDT 2016


Hi Guido,

sorry I missed your post...

>> One of the big issues that makes library authors reluctant to use
>> metaclasses
>> (even when they would be appropriate) is the risk of metaclass conflicts.
>
> Really? I've written and reviewed a lot of metaclasses and this has never
> worried me. The problem is limited to multiple inheritance, right? I worry a
> lot about MI being imposed on classes that weren't written with MI in mind,
> but I've never particularly worried about the special case of metaclasses.

Yes, the problem only arises with MI. Unfortunately, that's not
uncommon: if you want to implement an ABC with a class from a
framework which uses metaclasses, you have a metaclass conflict. So
then you start making MyFrameworkABCMeta-classes.

The worst is if you already have a framework with users out there. No
way you add  a metaclass to your class, however convenient it would
be. Because you never now if some user out there had gotten the idea
to implement an ABC with it. Sure, you could let your metaclass
inherit from ABCMeta, but is this really how it should be done?

(This has already been mentioned by others over at python-ideas:
https://mail.python.org/pipermail/python-ideas/2016-February/038506.html)

Greetings

Martin


More information about the Python-Dev mailing list