|Shed Skin - An Optimizing Python-to-C++ Compiler email@example.com (Mark Dufour) (2006-05-04)|
|From:||"Mark Dufour" <firstname.lastname@example.org>|
|Date:||4 May 2006 10:47:40 -0400|
|Keywords:||python, C++, available|
|Posted-Date:||04 May 2006 10:47:40 EDT|
I have developed an experimental Python-to-C++ compiler, called Shed
Skin, that accepts pure, but implicitly _statically_ typed Python
programs, and converts them into optimized C++ code. it can be used to
combine much of the productivity of Python, with much of the
efficiency of C++, (currently) for not too large programs. abstract
and generic types are supported, so that it allows one to write 'C++
programs at a higher level', using the nice Python syntax.
for my Master's Thesis, I have measured the speedup versus Psyco (a
'specializing' JIT compiler for Python) and CPython (the standard
Python interpreter), and found that generated code becomes typically
2-40 times faster than when using Psyco, 12 times on average, and
2-220 times faster than when using CPython, 45 times on average.
please see the Shed Skin homepage for more details, and a link to my
Master's Thesis (which explains in-depth how the compiler works) at:
there are several interesting optimizations to be added, to bring the
performance of generated code even closer to that of manually written
C++. most importantly, heap allocation can often be transformed into
stack- and static preallocation (I currently use a simple escape
analysis for this, but I am sure it can be done much better); I
currently also use the inefficient C++ STL string type to implement
strings, which can no doubt be greatly improved upon; there is
currently no simple way to interface with arbitrary Python standard
library calls; and the C++ implementation of the Python builtins, as
well as generated code, can probably be optimized much further (I am
no C++ expert!).
last year, Shed Skin was accepted as a Google Summer of Code project,
which helped tremendously. if anyone here would be interested in
looking at memory optimizations, for example, I feel there is a good
chance the PSF would accept such a project for this year. especially
memory optimizations would be a great Master's Thesis subject, too.
please let me know if you are interested, and we can cook up a nice
proposal for one of these.
in general, I feel the compiler is now clean and able enough (it's
only 6000 lines!) to invite others to join the project. if you are
interested, please have a look at the Shed Skin homepage and join the
mailing list. the sourceforge site is at
http://shedskin.sourceforge.net. I would also greatly appreciate bug
reports, as it's hard to fix problems I do not know about :-)
if vars: self.output('; '.join([self.nodetype(var)+' '+name for
(name,var) in vars.items()])+';')
Return to the
Search the comp.compilers archives again.