Skip to content

Demo of the optimisation of Pure Python code to its equivalent code in the Cython

Notifications You must be signed in to change notification settings

kartikeyporwal/cython_conversion_comparison

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python - Cython Introduction

Demo of the optimisation of Pure Python code to its equivalent code in the Cython. This project demonstrates the scope of the potential improvements/enhancements in the Python code for faster runtime.

Based on https://www.peterbaumgartner.com/blog/intro-to-just-enough-cython-to-be-useful/


Installation

python -m venv testenv

source testenv/bin/activate

python -m pip install -r requirements.txt


Demo iPython notebook that demonstrate each version: demo.ipynb


Steps

Compile the Cython Script: python setup.py build_ext --inplace


Result

Pure Python Code Execution

Fig.1 - Time Taken in Pure Python Code Execution

Pure Python Code Execution with Compilation

Fig.2 - Time Taken in Pure Python Code Execution with Compilation

Python Code Execution with C-Types

Fig.3 - Time Taken in Python Code Execution with C-Types

Python Code Execution with C-Types and Numpy Array Memory View

Fig.4 - Time Taken in Python Code Execution with C-Types and Numpy Array Memory View

References

About

Demo of the optimisation of Pure Python code to its equivalent code in the Cython

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published