[pypy-dev] opcodes bundled in a class?

Armin Rigo arigo at tunes.org
Mon Aug 4 15:18:44 CEST 2003

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...). It is a lexical
object. It can be stored in .pyc files or created by compile() out of pure
text. In some other programming languages, Python's code objects are blocks of
code (maybe whole function bodies, maybe smaller); and Python's function
objects are what they call "closures", and as with Python's "def" statement
they are created by capturing a block of code and some environment. (Python's
"closure" only means the tuple of nested-scope variables going from the parent
to the child function; in its broader sense "closure" refers to the whole
captured environment, which includes in Python the globals and the default


More information about the Pypy-dev mailing list