Profiling Cython

Cython provides a feature, called annotated view, that helps find which lines are executed in the Python interpreter and which are good candidates for ulterior optimizations. We can turn this feature on by compiling a Cython file with the -a option. In this way, Cython will generate an HTML file containing our code annotated with some useful information. The usage of the -a option is as follows:

$ cython -a cevolve.pyx$ firefox cevolve.html

The HTML file displayed in the following screenshot shows our Cython file line by line:

Each line in the source code can appear in different shades of yellow. A more intense color corresponds ...

Get Advanced Python Programming 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.