Skip to content

An example to test speed performance of Python vs C using the Cython Library. Also looks at 'numba' module for Python.

Notifications You must be signed in to change notification settings

AlexGidman/Cython-Performance-Test

Repository files navigation

Cython-Performance-Test

A quick look into Cython. This projects tests a simple prime number range calculation executed in Python and in C using Cython library.

EDIT A performance test using the 'numba' library has been added for reference.

How to Run:

  • Install the requirements:
pip install -r requirements.txt
  • Once you have cloned the repository and installed Cython, build the C code:
python setup.py build_ext --inplace
  • Then run:
python3 performance_test.py

Conclusion:

Using Cython runs much faster than Python. However, I did encounter several compilation issues when writing the .pyx file that did not contain much useful traceback information; this could be problematic for more complex programs.

Using the 'numba' library did improve performance, but not as much as Cython. For simple performance improvements in a large Python project, numba may prove sufficient.

About

An example to test speed performance of Python vs C using the Cython Library. Also looks at 'numba' module for Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages