Cython vs. Python - 3k times faster code! | Test @DataScienceGarage
Cython vs. Python - 3k times faster code! | Test  @DataScienceGarage
Uploaded August 2022 | Updated September 2026, 2 weeks ago
With this tutorial we will compare the performance betwen Cython and Python. Theoretically, Cython is much faster than Python. But how much? How we can to compare these two trending technologies? This video demonstrates how to write a simple function in Cython, and generate an executable Python file from it.

Cython is an intermediate step between Python and C/C++. It allows you to write pure Python code with some minor modifications, which is then translated directly into C code. In other words, The #Cython language is a superset (the extension of for Python) of the Python language that additionally supports calling C functions and declaring C types on variables and class attributes. This allows the compiler to generate very efficient C code from Cython code.

The chapters of the video:
0:00 - What is Cython?
0:50 - Write a Python function to test
1:46 - Write a Cython function to test
3:12 - Generate executable shared Cython object (setup.py)
5:41 - Test Cython function with a script
7:06 - Compare Python and Cython functions execution speed

All what we will use is standard Python, terminal and file explorer (Finder on Mac/Windows explorer on Windows).
Do not forget to install Cython on your machine with terminal command: pip install Cython

Some theory the video touched:
- While there is def in Python to write a function, then in Cython we are having #cpdef. This is called - FUNCTION DECLARATION topic. Learn more about this here: notes-on-cython.readthedocs.io/en/latest/function_declarations.html
- Official Cython documentation: notes-on-cython.readthedocs.io/en/latest/index.html
- Python #Setuptools module: pypi.org/project/setuptools
- Cython installation: pypi.org/project/Cython
- timeit module in Python: docs.python.org/3/library/timeit.html
- Cython website: cython.org

To complete this tutorial, you can clone the video code repository from Github: github.com/vb100/cython_vs_python

All the best and good luck with Cython & Python!
Subscribe the channel to get more fresh high-quality videos first! Thanks!
Your -Data Science Garage.
Cython vs. Python - 3k times faster code! | TestData Science Project StructureTwitter Streaming API in Python. Data mining DemonstrationInstall Jenkins on AWS EC2 InstanceSpark with Python. Operations Supported by Spark RDD APIAWS Machine Learning Specialty Exam - PASSED | My Experience, Practical Tests and TipsBuild and Run a Docker Container for your Machine Learning Model (Step by Step)Sankey Chart for Web Data Analytics and Visualization. Tableau  (My first Sankey diagram!)The Best Machine Learning Book I have. Review. 2020Correlation Test with p-value? Yes! | Pandas vs. ScipyRegia.lt. Web Scrapping Project  Lands and Parcel from GIS Maps. Real example.Spark with Python Course. Lesson 1. Create Parallelized Collection RDD
Data Science Garage |

Cython vs. Python - 3k times faster code! | Test

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER