Scalene is a nice tool for profiling Python code.
Install scalene. Then:
scalene
scalene example.py --html > profile.html