Many times a line-by-line timing description is necessary to understand where slow downs in the code exist. Just using %timeit in python can give you an understanding of how long functions take but not inidividual lines. There is a line-by-line profiler that has been developed on github here.
Install by:
$ pip install line_profilerKnow you should have a script called kernprof.py in your python's bin directory which will perform the profiling. Now add the @profile decorator to the function you wish to profile line-by-line:
@profile
def main(opts):
# do some work in function
# line 1
# line 2 ...
passThen evaluate performance:
$ python /path/to/kernprof.py -l -v myscript.py -v forces showing timing statistics.