用 shedskin 将你的 python 程序转成 C++ 代码 python转C pythontoc

 用 shedskin 将你的 python 程序转成 C++ 代码

 使用方法:
普通的话就直接:shedskin xxx.py 就可以了,注意 xxx.py 里面只能有数字,字母和下划线,其他滴不要(路径都不能有,刚刚没太注意,结果老是出警告:*ERROR*:./xxx.py: module names should consist of letters, digits and underscores),会在当前目录下生成一个 xxx.cpp, xxx.hpp 和一个 Makefile,完事以后直接 make 就会编译出一个可执行程序来的。

 

 

Under Windows, first execute (double-click) the init.bat file in the directory where you installed Shed Skin.

To compile the following simple test program, called test.py:

print 'hello, world!'

Type:

shedskin test

This will create two C++ files, called test.cpp and test.hpp, as well as a Makefile.

To create an executable file, called test (or test.exe), type:

 

 

http://code.google.com/p/shedskin/wiki/docs

文档在此

 

 注意:这个工具可以把python转为c++然后再转成.pyd或.so,这样python再调用.pyd和.so文件效率会提高很多

 

 


分享到: 微信 更多