Category: cProfile

Problem

Find bottlenecks with cProfile.

Solution

  cProfile.run('slow_function()', sort='cumtime')
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path