[pypy-dev] opcodes bundled in a class?

holger krekel hpk at trillke.net
Mon Aug 4 19:47:27 CEST 2003

[Armin Rigo Mon, Aug 04, 2003 at 03:18:44PM +0200]
> Hello Holger,
> On Mon, Aug 04, 2003 at 12:08:02PM +0200, holger krekel wrote:
> > Please let me clarify the concepts behind the current builtinrefactor
> > branch.  The main point of the refactoring was to channel all calls to
> > app-level code mainly through two classes:
> > 
> > ScopedCode:  a code object with a global and closure scope.
> > (...)
> > InterpretedFunction:
> >              a function which will be interpreted at app-level. 
> >              it derives from ScopedCode and you can use it ala:
> > (...)
> I still find this confusing. I believe that the distinction between code
> objects and functions in pretty fundamental in Python. A code object has no
> closure whatsoever (reference to global, to default args...).

right before you interpret it you must place it into a context
of global(, closure) and local scopes.  

> It is a lexical object. 

'ScopedCode' was not meant to be such a plain code object. It's rather wrapping
a plain lexical code object (the cpy one) and tying it into a context of scopes.  
Maybe the name 'ScopedCode' is not perfect but without this concept you 
have a lot of boilerplate at various places dealing with code objects
and scopes. To me it seemed that the steps

    1. tying a code object to certain scopes
    2. creating the frame / possibly parsing arguments into locals
    3. executing the frame

are a useful separation of concerns.



More information about the Pypy-dev mailing list