snakeviz is a very nice tool to inspect a python program and find out what happened when a function is called.

It also shows the time consumed on each step.