0

my Python program is slow and I wanted to test if it would speed up if I complied it (with code optimization) and executed it afterward.

So what are the terminal commands to do so? I'm searching for something like

pythoncompile -optimize my_code.py my_compiled_code.out
pythonexecute my_compiled_code.out

Thank you

1 Answer 1

1

Python source code is automatically compiled into Python byte code by the CPython interpreter. Compiled code is usually stored in PYC (or PYO) files, and is regenerated when the source is updated, or when otherwise necessary.

Generally speaking; you can speed up execution with better hardware, or with code optimization by rewriting your code.

For example you can use the python profilers to look for weak spots in execution time.

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

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.