Profiling

In this section, we will discuss profilers and take a deep look at the modules in the Python standard library, which provides support for deterministic profiling. We will also look at third-party libraries that provide support for profiling such as line_profiler and memory_profiler.

Deterministic profiling

Deterministic profiling means that all function calls, function returns, and exception events are monitored, and precise timings are made for the intervals between these events. Another type of profiling, namely statistical profiling, randomly samples the instruction pointer and deduces where time is being spent—but this may not be very accurate.

Python, being an interpreted language, already has a certain overhead in terms of metadata ...

Get Software Architecture with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.