Bytecode optimisation

Markus Stenberg mstenber at cc.Helsinki.FI
Wed May 19 09:05:59 EDT 1999


Martijn Faassen <faassen at pop.vet.uu.nl> writes:
..snip..

> I think the tricky parts are adding the type info to Swallow parse tree
> (along with the type info for lots of builtin stuff), and then turning
> this tree into the C tree.

The later part at least, is definitely painful. 

> Perhaps someone already has a python module that can generate C code
> from some tree structure?

Python2C produces C from Python parse tree
(http://lima.mudlib.org/~rassilon/p2c/). 

> Random note: I think we need a form of C++ templates or generic
> classes/types in order to do enough of Swallow. For instance, we need a
> list(integer) and list(float) and list(fooClass). Some system of generic
> programming seems necessary here.

Hell no. You should use Python's internal list/dict at least in the first
place, and C++ in general is evil. (Especially as rest of Python is C)

> > It may be nescessary to keep two or more copies of a function around (if you
> > want both speed and flexibility).. one optimized to flash powder in native
> > code, one in the original python bytecode.
> Yes, I had the same idea.

Or even 3 functions;
	- internal C function (just used in C->C calls)
	- external C function wrapper (to be callable from Python and to
	return things in Pythonese fashion)
	- pure Python function (original bytecode)

> Regards,
> 
> Martijn

-Markus

-- 
"One World, One Web, One Program" - Microsoft Promotional Ad
"Ein Volk, Ein Reich, Ein Fuhrer" - Adolf Hitler

We don't see a similarity. We really don't.




More information about the Python-list mailing list