[pypy-dev] opcodes bundled in a class?

Armin Rigo arigo at tunes.org
Tue Aug 5 10:43:34 CEST 2003

Hello Christian,

On Tue, Aug 05, 2003 at 02:14:09AM +0200, Christian Tismer wrote:
> Maybe I've read not enough of context, but if I only can call
> a function object, how are then classes and complete
> modules executed?

Point taken. In Python a code object can be executed either with 
PyEval_EvalCode(), which takes few arguments, or PyEval_EvalCodeEx(), which 
has tons of arguments.

> In standard Python, a frame is created for a code object, together
> with parameters and additional info, which may, but needn't
> come from a function object (speaking of closures).
> Why not stick with this?

I suggest then the following interface:

1. code objects have a create_frame(w_globals) that creates a new empty frame;
2. function objects have a parse_args(frame, w_args, w_kwargs) that does the 
argument decoding dance and fills the given frame;
3. frame objects can be executed with eval().

So if we have no particular arguments to give to the code object, as in the
case of class bodies and modules, we only do steps 1 and 3. The step 2
replaces the PyEval_EvalCodeEx() functionality by avoiding the need for a
routine with hundreds of arguments (these arguments are exactly the fields of
the function object).

A bientot,


More information about the Pypy-dev mailing list