[Python-3000] pyvm module - low level interface to Python's VM

Christian Heimes lists at cheimes.de
Mon Dec 3 15:48:58 CET 2007


Nick Coghlan wrote:
> Aren't the metaclass changes in PEP 3115 partially aimed at eliminating 
> the need for stack frame hackery to implement these kinds of things? 
> (e.g. the metaclass could stuff a closure into the class namespace under 
> the name 'implements' to avoid any need for frame hackery).

Couldn't we use a similar approach like the new super() magic? As far as
I remember super() can access its class through a new cell '__class__'.
Maybe we could introduce a similar way to access the namespace of a
class during its construction time?

class Example:
    implements(IExample)

def implements(*args):
    # The non local variable __class_ns__ is the namespace of the
    # class aka the dict returned by the __prepare__ function of
    # the meta class.
    nonlocal __class_ns__
    ...
    __class_ns__['spam'] = ...

Christian



More information about the Python-3000 mailing list