[Python-3000] Compiling the PEP 3115 metaclass syntax (original) (raw)
Phillip J. Eby pje at telecommunity.com
Thu Mar 15 17:23:48 CET 2007
- Previous message: [Python-3000] I18N identifiers
- Next message: [Python-3000] Compiling the PEP 3115 metaclass syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 LOADLOCALS opcode we need a STORELOCALS 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.
So in this:
def buildclass(func, name, *bases, metaclass=None, **kwds): if metaclass is None: metaclass = extractmetaclass(bases) # may raise an exception prepare = getattr(metaclass, "prepare", None) if prepare: locals = prepare(name, bases, **kwds) else: locals = {} func(locals) return metaclass(name, bases, locals, **kwds)
we would change 'func' to 'code' and instead of func(locals) we would 'exec code in globals, locals'.
- Previous message: [Python-3000] I18N identifiers
- Next message: [Python-3000] Compiling the PEP 3115 metaclass syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]