Python is a powerful programming language that is easy to learn and easy to work with, but it is not always the fastest to run—especially when you’re dealing with math or statistics. Third-party libraries like NumPy, which wrap C libraries, can improve the performance of some operations significantly, but sometimes you just need the raw speed and power of C directly in Python.

Cython was developed to make it easier to write C extensions for Python, and to allow existing Python code to be transformed into C. What’s more, Cython allows the optimized code to be shipped with a Python application without external dependencies.

In this tutorial we’ll walk through the steps needed to transform existing Python code into Cython, and to use it in a production application.

A Cython example

Let’s begin with a simple example taken from Cython’s documentation, a not-very-efficient implementation of an integral function:



Source link


Computers and Software Buyers Guide

Compare Computers and Laptops

Mobile Phones Buyers Guide

Compare Mobile Phones

Game Console Buying Guide

Compare Game Consoles


Tech Shop Offers


Shop Categories