简体   繁体   English

使用 PyPy 构建 Python 文件

[英]Build Python File with PyPy

I have python file.我有python文件。 If i run this file with python it takes 100 seconds to finish.如果我用 python 运行这个文件,它需要 100 秒才能完成。 If I run this python file with PyPy3 windows 32bit, it just takes 20 seconds.如果我用 PyPy3 windows 32bit 运行这个 python 文件,它只需要 20 秒。 I will share my python file.我将分享我的python文件。 So Is it possible to run this script with pypy in non installed pypy another computer without copy pypy folder?那么是否可以在未安装 pypy 的另一台计算机中使用 pypy 运行此脚本而无需复制 pypy 文件夹? Is it possible to compile python file with pypy?是否可以用pypy编译python文件? Like Cython?像 Cython?

I am using right now like this;我现在就是这样使用的;

os.system("C:\\pypy3\\pypy3.exe myPythonFile.py functionName parameters")

Thank you everyone :)谢谢大家 :)

Pypy is an alternative Python interpreter (which internally uses a just-in-time compiler). Pypy 是另一种 Python 解释器(内部使用即时编译器)。 It is not a compiler.它不是编译器。 Therefore it is not possible to compile a module to run through PyPy.因此,无法编译模块以通过 PyPy 运行。 Their FAQ has the question "Couldn't the JIT dump and reload already-compiled machine code?"他们的常见问题解答有一个问题“JIT 不能转储并重新加载已经编译的机器代码吗?” , and the answer is "no". ,答案是否定的。

It is also not possible to run individual modules in PyPy when the rest is using CPython.当其余模块使用 CPython 时,也不可能在 PyPy 中运行单个模块。 You either need to run your whole program in one or other other (or use system-calls as you're doing).您要么需要以一种或另一种方式运行整个程序(或在执行时使用系统调用)。

It does have the ability to translate RPython (a restricted subset of Python, where the restrictions are basically undocumented) to an executable, which is what it uses to build itself.它确实能够将 RPython(Python 的一个受限子集,其中的限制基本上没有记录)转换为可执行文件,这是它用来构建自身的。 This is not recommended. 不建议这样做。 . .


In summary, what you're trying to do isn't possible and is nowhere near the purpose of PyPy.总之,您尝试做的事情是不可能的,而且与 PyPy 的目的相去甚远。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM