它是编译的Python机器code是否可行? [英] Is it feasible to compile Python to machine code?

查看:83
本文介绍了它是编译的Python机器code是否可行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何可行的会是(通过中间c重新presentation可能)编译的Python成机器code?

How feasible would it be to compile Python (possibly via an intermediate C representation) into machine code?

presumably那就需要链接到一个Python运行时库,并为Python的本身将需要编译(和链接中)太Python标准库的任何部分。

Presumably it would need to link to a Python runtime library, and any parts of the Python standard library which were Python themselves would need to be compiled (and linked in) too.

此外,您还需要捆绑Python的跨preTER如果你想要做的前pressions的动态评价,但也许Python中的一个子集,并没有让这仍然将是有益的。

Also, you would need to bundle the Python interpreter if you wanted to do dynamic evaluation of expressions, but perhaps a subset of Python that didn't allow this would still be useful.

它会提供任何速度和/或内存使用情况的优势? presumably Python的跨preTER的启动时间将被淘汰(尽管共享库仍需要在启动时加载)。

Would it provide any speed and/or memory usage advantages? Presumably the startup time of the Python interpreter would be eliminated (although shared libraries would still need loading at startup).

推荐答案

尝试 ShedSkin 的Python到C ++编译器,但它远非完美。也有使用Psyco - Python的JIT如果只需要加速。但恕我直言,这是不值得的努力。对于code的速度关键部分最好的办法是把它们写为C / C ++的扩展。

Try ShedSkin Python-to-C++ compiler, but it is far from perfect. Also there is Psyco - Python JIT if only speedup is needed. But IMHO this is not worth the effort. For speed-critical parts of code best solution would be to write them as C/C++ extensions.

这篇关于它是编译的Python机器code是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆