Python Profiling & Performance

Profiling Methods

python -m cProfile -o out.prof do.py

Visualisation

Use snakeviz.

Install pipx install snakeviz.

snakeviz out.prof

Other

Austin.

austin -f -o out.prof python3 do.py

Austin can attach to running programs.

I haven't worked out how to visualise this.

Performance Tips

SQLAlchemy

Something something 'raise' to prevent hidden n+1 joins.