[Python-3000] Metaclasses in Py3K

Thomas Wouters thomas at python.org
Tue Dec 12 20:07:07 CET 2006


On 12/12/06, Phillip J. Eby <pje at telecommunity.com> wrote:
>
> At 10:11 AM 12/12/2006 -0800, Thomas Wouters wrote:
>
>
> >On 12/12/06, Jim Jewett
> ><<mailto:jimjjewett at gmail.com>jimjjewett at gmail.com> wrote:
> >>On 12/8/06, Guido van Rossum <<mailto:guido at python.org>guido at python.org>
> >>wrote:
> >> > I've been thinking about this too, and I think it's reasonable to let
> >> > the metaclass provide the dict to be used as locals.
> >
> >I do wonder about this though: will it require a particular type (like a
> >dict)? The current code uses fast locals,
>
> Uh, wha?  Did this change in Py3K?  Python 2.x doesn't do this and can't
> do
> it without introducing backward incompatibility.  In 2.x, class bodies do
> NOT use fast locals, any more than module bodies do.
>
> In any case, the performance within the class suite isn't especially
> important; it's rare that there are any loops within a class body, or that
> one creates classes within frequently-executed loops.


I apologize. It doesn't use STORE_LOCAL. It is, however, executed as a
normal function, and uses STORE_NAME. So the impact would be limited to that
of changing a function's non-fast locals from a dict to an arbitrary mapping
type. (Provided we don't specialcase class creation.)

I do wonder why classes don't use fast locals, though. Building the locals
dict from the fast locals at the end of the class suite execution seems more
logical to me than what happens now... but I agree that it doesn't really
matter.

-- 
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20061212/8529356b/attachment.htm 


More information about the Python-3000 mailing list