Stefan Behnel, 04.11.2010 14:17:
> BTW, I'll ask on python-dev about the way __build_class__ works here.

;) writing e-mails about a problem without sending them away is the best 
way to understand the topic.

Ok, so, __build_class__ is actually ok, because it *is* the point where the 
class body is evaluated. So, __prepare__ is really called before the 
evaluation of the body (which is done in a "function" call near the end) 
and the metaclass is called afterwards.

We could essentially do the same thing in Cython. At the point where the 
class dict is now getting instantiated, we need to put the code of the 
first part of __build_class__, i.e. look up the metaclass from the keywords 
and find and call its __prepare__ method. Then, evaluate the class body 
into the class namespace object that __prepare__ returned, followed by the 
call to __Pyx_CreateClass().

If we don't find a metaclass in the keywords, we do not support __prepare__ 
but try to look up the __metaclass__ field in the class namespace during 
__Pyx_CreateClass().

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to