(或者,“可以使用 PyPy/RPython 将 Python 编译/翻译为 C/C++不需要 Python 运行时?")
我试图通过它的 RPython 和 Python、它的运行、它的编译和它的翻译来理解 PyPy,但有些失败。
I have a hypothetical Python project (for Windows); I would like to keep its size down, in the order of a hundred kilobytes (O.N.O.) rather than the several megabytes that using py2exe entails (after UPX). Can I use PyPy1 in any way to produce a standalone executable which does not depend on Python26.dll? If I can, does it need to follow the RPython restrictions like for
only working on builtin types, or is it full Python syntax?
我确实意识到,如果可以做到这一点,我几乎肯定无法直接使用 Python 中的 C 模块。
1 (Since the time of asking, the situation has become clearer, and this part of the toolchain is more clearly branded as RPython rather than PyPy; it wasn't so in 2010.)
是的,PyPy 可以从 RPython 代码生成独立的可执行文件。这意味着,在编写代码时,您需要遵循所有尴尬的 RPython 规则。您的 Python 代码完全不可能开箱即用,并且移植现有的 Python 代码通常并不有趣。它不会使可执行文件像 C 一样小,但例如使用 boehm GC 的 rpystone 目标(来自 pypy/translator/goal)在剥离后在 64 位上为 80k。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)