Book Image

Mastering Python High Performance

Book Image

Mastering Python High Performance

Overview of this book

Table of Contents (15 chapters)


This profiler is different from cProfile. It helps you profile a function line by line instead of doing a deterministic profiling, like the other one does.

To install this profiler, you can use the pip ( command-line tool, with the following command:

$ pip install line_profiler


If you run into any trouble, such as missing files during installation, make sure you have all development dependencies installed. In the case of Ubuntu, you can ensure that all the dependencies are installed by running the following command:

$ sudo apt-get install python-dev libxml2-dev libxslt-dev

This profiler is trying to fill in a breach left by cProfile and others like it. Other profilers cover CPU time on function calls. Most of the time, this is more than enough to catch the problems and fix them (we saw that earlier). However, sometimes, the problem or bottleneck is related to one specific line inside the function and that is where line_profiler comes into...