How to assess your code performance in Python

cProfile and line_profiler

Sophia Yang, Ph.D.
Towards Data Science
3 min readDec 23, 2020

--

Profiling helps us identify bottlenecks and optimize performance in our code. If our code runs slowly, we can identify where our code is slow and then make corresponding improvements.

Here are the explanations of Python profilers from the Python documentation:

cProfile and profile provide deterministic profiling of Python programs. A profile is a set of statistics that describes how often and for how long various parts of the program executed…cProfile is…

--

--