On 7/13/07, Talin <[EMAIL PROTECTED]> wrote:
> 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 intention is that it's up to the metaclass to decide. I suspect that
> most metaclasses won't want to use the dict-like object as the class
> dict, for two reasons:
>
> 1) The behavior of assigning to the class dict after class creation is
> likely to be different than the behavior of assignment during class
> creation. In particular, a typical 'dict-like' object is likely to be
> slower than a dict (it has more work to do, after all), and you don't
> want that slowness around once your class is finished initializing.
>
> 2) A 'dict-like' object doesn't have to support all of the methods of a
> real dict, wherease a class dict does. So your dict-like wrapper can be
> relatively simple.

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.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to