[OT] Compilable Python-like language?

Greg Ewing (using news.cis.dfn.de) ieyf4fu02 at sneakemail.com
Thu Mar 25 04:25:19 CET 2004


Ed Cogburn wrote:
> 
> Pyrex is very interesting, I've looked at Pyrex code.  The purpose of 
> Pyrex however isn't to replace Python or the interpreter process, merely 
> to optimize some parts of a Python program.  Even with heavy use of 
> Pyrex, you still can't get away from the interpreter process, ie., 
> Python will always have to be there, right?

If you use any Python features, then at least some of the
interpreter code will need to be present as a run-time
library.

If you write Pyrex code that uses no Python features at all,
Pyrex could in principle generate code that was independent
of the interpreter (it won't quite, as it stands, but it
could be made to do so). But then there wouldn't be much
advantage over writing directly in C.

As for speed, the more Python features you use, the slower
things will be. Pyrex could be smarter than it is when
translating Python code, but there are limits to what could
be achieved. There was an earlier project called Python2C
that translated Python code into a series of calls to the
Python/C API, much as Pyrex does. Reportedly it managed to
produce code that was up to about 3 times faster than
interpreted Python, but no better.

So, to get speed, you're going to have to give up some of
Python's dynamism, one way or another.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list