0

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

3
  • just run the interpreter ... afaik cx_freeze just unpacks everything and runs its own interpreter Commented Jul 23, 2013 at 19:38
  • 2
    Performance stuff can vary a lot by system--might be helpful if you include some details about your deployment environment. Commented Jul 23, 2013 at 19:39
  • @Prime I've edited the question to provide more info Commented Jul 23, 2013 at 19:48

2 Answers 2

3

You need to test it, because there's no single right answer. All cx_freeze does is wrap up the bytecode into an executable, vs. the interpreter reading from its cached .pyc on disk.

In theory the packaged executable could be quicker because it's reading fewer files, but on the other hand the interpreter could be quicker because it could already be in the disk cache.

There's likely to be little to choose, and whatever the difference is, it's not down to "compiled" vs. "interpreted".

Sign up to request clarification or add additional context in comments.

Comments

3

cx_freeze (and the various competitors for "compiling" Python code to executables) don't actually compile anything. They're just a convenient way of packaging the app in such a way that it can be run directly. In other words, there's no performance difference.

Depending on what you need to do in your Python script, you could consider using Pypy to improve your performance.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.