[Python-3000] pep3115 - metaclasses in python 3000 (original) (raw)
Phillip J. Eby pje at telecommunity.com
Fri Jul 13 23:51:52 CEST 2007
- Previous message: [Python-3000] pep3115 - metaclasses in python 3000
- Next message: [Python-3000] pep3115 - metaclasses in python 3000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 09:13 PM 7/13/2007 +0200, Thomas Heller wrote:
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?
I would suggest that we do not intend that the class dict == the prepare object, even as the default case. Otherwise, we have to find everything that accesses type dictionaries and make sure they can work with other kinds of objects.
- Previous message: [Python-3000] pep3115 - metaclasses in python 3000
- Next message: [Python-3000] pep3115 - metaclasses in python 3000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]