أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
I'm planning to use python to build a couple of programs to be used as services, run from PHP code later on. In terms of performance, which is faster, to compile the python code into a binary file using cx_freeze or to run the python interpreter each time I run the program? Deployment environment: OS: Arch Linux ARM Hardware: Raspberry Pi [700MHz ARMv6 CPU,256MB RAM, SD Card filesystem] Python Interpreter: Python2.7 App calls frequency: High
Python is compiled (to machine code) at run-time every time either from source code (.py) or from byte code (.pyc or .pyo).
Python is compiled at first run into byte code in .pyc files (python compiled). If your .py files are more recent, Python will re-compile your files and replace the old .pyc files.
Python compiled files can be optimized, just a little so far, into .pyo files. To compile files in optimized format, run Python interpreter using '-o' flag without quotes.
You can double the optimization by using the flag '-oo' without quotes. In some rare cases, this may damage your code and render it unusable. This flag is not recommended unless you know exactly what you are doing.
Access rights may prevent the interpreter from generating the byte code compilation of your .py files.
Finally, and to answer your question, performance is not affected unless your .py files are too large. This is due to loading time only, not execution time.