I am looking to compile python source code into a binary. I generally use pypy for performance reasons (my application runs significantly faster using pypy). I found this answer from 2012 stating compiling pypy into binary isn't possible using any of the existing tools (e.g. pyinstaller). Compile PyPy to Exe. I wasn't quite able to follow what the top response was explaining as a solution.
I am wondering:
Is there now a reasonably easy way to compile python code to binary using pypy as the interpreter?
I don't actually need to use pypy, I just use it for the performance gains. Is there a reasonable way to avoid using pypy but still get similar performance gains? This would still need to support compiling to binary.
As an additional note, I use the 2.7 syntax.
On the average, PyPy speeds up Python by about 7.6 times, with some tasks accelerated 50 times or more. The CPython interpreter simply doesn't perform the same kinds of optimizations as PyPy, and probably never will, since that is not one of its design goals.
It's worth noting that while running a compiled script has a faster startup time (as it doesn't need to be compiled), it doesn't run any faster. It's worth noting that while running a compiled script has a faster startup time (as it doesn't need to be compiled), it doesn't run any faster. A common misconception.
PyPy often runs faster than CPython because PyPy uses a just-in-time compiler. Most Python code runs well on PyPy except for code that depends on CPython extensions, which either does not work or incurs some overhead when run in PyPy.
Because of the inherent dynamism of Python, it's impossible to compile Python into a standalone binary and reuse it. PyPy is a runtime interpreter that is faster than a fully interpreted language, but it's slower than a fully compiled language such as C.
you can take a look to nuitka ( http://nuitka.net/doc/user-manual.html)
nuitka --standalone --recurse-on --python-version=2.7 main.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With