Shedskin 0.0.14
http://sourceforge.net/projects/shedskin/
Python to C++ converter。
Boehm-Demers-Weiser GCに依存していて、ライセンスはGPL。
Pythonの基本機能をC++ライブラリで提供して、それに利用したC++コードに変換するみたい。
Linuxだけでなく、Windowsでも動くコードを吐いてくれるみたいだ。
とりあえずサンプルでついてくるHello, WorldプログラムをC++コードに変換させてみる。
% python test.py hello, world! % ./ss.py test.py *** SHED SKIN Python-to-C++ Compiler 0.0.14 *** Copyright 2005, 2006 Mark Dufour; License GNU GPL version 2 or later (See LICENSE) (If your program does not compile, please mail me at mark.dufour@gmail.com!!) [iterative type analysis..] ** iterations: 2 templates: 11 [generating c++ code..] % make run g++ -O3 -I. ./builtin_.cpp test.cpp -lgc -o test ./test hello, world!
ちなみにPythonの中身はこんな感じ。
print 'hello, world!'
#include "test.hpp" namespace __test__ { str *const_0; int __main() { const_0 = new str("hello, world!"); print("%s\n", const_0); } } // module namespace int main(int argc, char **argv) { __shedskin__::__init(); __test__::__main(); }
思ったより綺麗なコードを生成するなぁ、感心。
筆者のblogエントリーを見る限り、pygameみたいな外部ライブラリ対応の道筋も出来つつあるみたいなので、α版ですが、大分期待してます。
http://shed-skin.blogspot.com/#115277992605370824
パフォーマンスにどの位差がでるのか、複雑なPythonコードでどの程度C++コードが読めなくなるのか、もちょっと弄ってみよう。