[Python-Dev] Possible rough edges in Python 3 metaclasses (was Re: Language reference updated for metaclasses)

Nick Coghlan ncoghlan at gmail.com
Wed Jun 6 09:09:06 CEST 2012


On Wed, Jun 6, 2012 at 1:28 AM, PJ Eby <pje at telecommunity.com> wrote:
> To be clear, what I specifically proposed (as I mentioned in an earlier
> thread) was simply to patch __build_class__ in order to restore the missing
> __metaclass__ hook.  (Which, incidentally, would make ALL code using
> __metaclass__ cross-version compatible between 2.x and 3.x: a potentially
> valuable thing in and of itself!)
>
> As for metaclasses being hard to compose, PEP 422 is definitely a step in
> the right direction.  (Automatic metaclass combining is about the only thing
> that would improve it any further.)

Just as a warning, I doubt I'll be able to persuade enough people that
this is a feature worth including in the short time left before 3.3
feature freeze. It may end up being necessary to publish metaclass
and explicit decorator based variants (with their known limitations),
with a view to gaining support for inclusion in 3.4.

Alternatively, if people can supply examples of "post-creation
manipulation only" metaclasses that could be replaced with cleaner and
more composable dynamic decorator based solutions, that could help
make the PEP more compelling in the near term (perhaps compelling
enough to make it into 3.3).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list