June 2017
Beginner to intermediate
274 pages
6h 49m
English
Cython allows two import mechanisms in addition to the normal ones provided by Python packages. Let's check out these mechanisms in detail.
The first mechanism is called cimport, and it imports the signatures of compiled functions and data structures from pre-prepared libraries, as shown in the following command line:
from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free
In this case, since Cython comes with a pre-prepared library of all Python C API functions, we were able to use this mechanism to report the needed information about Python's low-level memory allocation and de-allocation functions.
The second additional importing mechanism is cdef extern from. When we don't already have the ...
Read now
Unlock full access