django-planet
May 19, 2025

Python: a quick cProfile recipe with pstats

published by Adam Johnson
in blog Adam Johnson
original entry Python: a quick cProfile recipe with pstats

Python comes with two built-in profilers for measuring the performance of your code: cProfile and profile. They have the same API, but cProfile is a C extension, while profile is implemented in Python. You nearly always want to use cProfile, as it’s faster and doesn’t skew measurements as …