[Python-3000] pep3115 - metaclasses in python 3000

Guido van Rossum guido at python.org
Tue Jul 17 02:11:09 CEST 2007


On 7/16/07, Guido van Rossum <guido at python.org> wrote:
> The object returned by __prepare__() actually *is* incorporated into
> the class object, unless the metaclass' __new__() passes something
> else to type.__new__(). However this isn't obvious when you ask for
> the class' __dict__ attribute: you always get a dict proxy.

I take it back. The object is copied, for the reasons Phillip
explained. There is no way around this without writing C code, as the
only way to create a type object from Python is to call type.__new__()
-- the __new__() method if a subclass of type still must call type's
__new__() method to create the actual object.

(Embarrassed, since I wrote all the code involved.)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list