Python is distributed with profiling modules. They describe the run time operation of a pure python program, providing a variety of statistics.
The cProfile module is the recommended module. To execute your program under the control of the cProfile module, a simple form is:
$ python -m cProfile -s cumulative mypythonscript.py
» Alain Leufroy | logilab.org