[Python-3000] pep3115 - metaclasses in python 3000
Thomas Heller
theller at ctypes.org
Fri Jul 13 21:13:39 CEST 2007
playing a little with py3k...
pep3115 mentions that "__prepare__ returns a dictionary-like object
which is used to store the class member definitions during evaluation
of the class body."
It does not mention whether this dict-like object is used afterwards
as the class-dictionary of the created class or not (when the __new__
method of the metaclass is called).
The sample-code suggests that it would be used as class dict of the
newly created class (the sample code copies it into a regular dictionary
before it is passed to the type.__new__ call).
However, the actual code in the py3k-struni branch (typeobject.c) copies
the passed in dict again.
In other words, it seems impossible even with pep3115 to use a custom
subclass of dict as a type's __dict__ member, and afaik it is impossible
in Python to replace that afterwards.
Is this analysis correct? Is that the intent of pep3115? Or could
the code be changed so that it is possible to supply a custom type dict
with the metaclass?
Thanks,
Thomas
More information about the Python-3000
mailing list