Python might be one of today’s most popular programming languages, but it’s definitely not the most efficient. In the machine learning world in particular, practitioners sacrifice efficiency for the ease-of-use that Python offers.
That doesn’t mean that you can’t speed things up in other ways. Cython is an easy way to significantly lessen computation time of Python scripts, without sacrificing the functionality easily achieved using Python.
This tutorial will introduce you to using Cython to speed up Python scripts. We’ll look at a simple yet computationally expensive task: creating a for loop that iterates through a Python list of 1 billion numbers, and sums them. Since time is particularly important when running code on resource-limited devices, we’ll put this issue into context by considering how to implement Python code in Cython on Raspberry Pi (RPi). Cython makes a significant change in the speed of calculation. Think of it like a sloth compared to a cheetah.
The sections covered in this tutorial are as follows:
Let’s get started.
#python #cython #paperspace #linux #raspberry-pi