Python Performance Tips
There are a lot of ways to gain massive speed improvements in Python. In this post I will list different resources to learn how to obtain these improvements (and to use Python for compute-intensive tasks). If you have encountered other interesting talks, modules, websites, tips, please feel free to inform me.
Python internals, general talks:
- How to Speed up a Python Program 114,000 times(YouTube)
- A Billion Rows per Second: Metaprogramming Python for Big Data (YouTube)
- general Python performance tips (old page)
- PyPy performance tips
- High Performance Python (slides)
Profiling:
Numpy tips:
- Numpy tutorial
- Numba: this is a just-in-time specializing compiler which compiles annotated Python and NumPy code to LLVM (through decorators). Its goal is to seamlessly integrate with the Python scientific software stack and produce optimized native code, as well as integrate with native foreign languages. (Example)(tutorial)
- Numpy performance tricks
- Parakeet: alternative JIT compiler
- Vector Byte Code (cphVB) (YouTube)
Alternative Python Implementations:
Another alternative is to use other Python implementations:
- Cython: write C extensions for your Python code and add static typing
- PyPy: just-in-time (JIT) compilation
- Jython: dynamic compilation to Java bytecode that runs in JVM
Distributed computing:
GPU programming:
Scientific Python Distributions:
There are optimized Python distributions available, containing multiple useful scientific modules.