Member-only story

Run Your Python Code as Fast as C

How you can supercharge the performance of your python code without changing a thing.

Marcel Moosbrugger
Towards Data Science
5 min readApr 18, 2021

--

Image by Onur Ömer Yavuz from Pixabay

As a PhD researcher, it is crucial for my job to quickly code up an idea to see if it works or not. Python is an excellent tool enabling just that. It allows for focusing on the idea itself and not be bothered with boilerplate code and other tedious things.

However, Python comes with a major drawback: It is much slower than compiled languages like C or C++. So, what do we do after we tested an idea by building a Python prototype and now we want to turn it into a fast and performant tool? Most often than not, we end up doing twice the work and manually converting the Python code into C. Wouldn’t it be great, if our Python prototype itself could run faster? All the time spent on implementing everything twice could be used for something more meaningful and fun.

Fortunately, I stumbled upon a solution to the problem: PyPy, a fast alternative to Python.

--

--

Towards Data Science
Towards Data Science

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Marcel Moosbrugger
Marcel Moosbrugger

Written by Marcel Moosbrugger

I am a Ph.D. researcher, enjoying explaining complex things in simple terms || marcelmoos.com || Follow for more: marcelmoos.com/newsletter

Responses (24)