[Python-3000] Compiling the PEP 3115 metaclass syntax

Guido van Rossum guido at python.org
Thu Mar 15 18:12:53 CET 2007


On 3/15/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 06:26 PM 3/14/2007 -0700, Guido van Rossum wrote:
> >(It's a slightly
> >different function than currently; the current function *returns* the
> >locals, while the new one *takes* the locals as an argument; instead
> >of a LOAD_LOCALS opcode we need a STORE_LOCALS opcode.)
>
> Wouldn't it suffice to exec a code object with the specified locals?  Then
> the class suite wouldn't even need to be a function, since it would neither
> accept parameters nor return results.  And no new opcode would be needed.

This was brought up twice now, and I initially drafted it that way,
but then I started to think about closures and after looking at the
byte code for a class whose methods reference closures I realized that
making it a function is necessary to pass the closures in. Unless
there's a different way to deal with closures at the C level.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list