Too Long; Didn't Read
You can benchmark your Python code line by line using line_profiler. This benchmarking library has significant overhead, but it's perfect for finding weak points in your code and replacing them with something more efficient. Avoid loops when possible. Compile your Python modules using Cython or Cython. Cython is not a general purpose python to C compiler, Cython lets you compile your python modules into shared object files(so), which can be loaded by your main python script. For example, the map version is over 6X faster than the original.