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

Paul Moore p.f.moore at gmail.com
Fri Nov 30 17:52:05 CET 2007


On 30/11/2007, Barry Warsaw <barry at python.org> wrote:
> >> class Example:
> >>    implements(IExample)
>
> This frame hacking is also a pretty common feature of other types of
> systems, such as ORMs.  It can make certain Python code much more
> readable, so "frame hacking" is clearly a useful feature, at least it
> seems, in the context of a class definition.  Is there a way to
> promote this to an API that's more principled than the sys._getframe
> () hack, and thus more acceptable to Guido and more portable to other
> implementations?
>
> (Or is something like this already in Py3K, and I just haven't
> noticed it yet? ;).

There's class decorators:

    @implements(IExample)
    class Example:
        pass

which could provide the same result in effect, but (as J-P points out)
it's still an API change and so not a direct replacement. IIRC, one of
the arguments for class decorators was that they are a way to avoid
the need for some of this getframe hacking, though.

Paul.


More information about the Python-3000 mailing list