[Python-ideas] Simpler Customization of Class Creation - PEP 487

Martin Teichmann lkb.teichmann at gmail.com
Tue Feb 9 02:44:39 EST 2016


> This new ProvisionalMeta will allow multiple inheritance of metaclasses
> using standard left-to-right priority (or the MRO for more depth). In the
> case of two metaclasses, the code from Left will run immediately after the
> class is created and the code from Right will go next. Right? (joking. I
> should say "Correct?")

No. The upshot is: metaclasses are complicated, especially if you want
to combine two of them. But most uses of the usecases fall into one of
the three mentioned categories. So we just write one metaclass that
serves those use cases, everyone can simply use the very same metaclass,
so the are no conflicts anymore as there *is* only one metaclass. Eventually,
this one metaclass shall become the builtin type, and so we don't need
metaclasses anymore in most usecases.

The proposed metaclass (current working title: types.Type) will call
a hook for users to customize its behavior. This hook will use the normal
Python cooperative multiple inheritance scheme, which also has its
very own problems, but known and solvable problems. The current
metaclasses, on the other hand, once you use two of them open a
complete new box of pandora.

Greetings

Martin


More information about the Python-ideas mailing list