Cython: cimport and import numpy as (both) np

cimport my_module gives access to C functions or attributes or even sub-modules under my_module

import my_module gives access to Python functions or attributes or sub-modules under my_module.

In your case:

cimport numpy as np

gives you access to Numpy C API, where you can declare array buffers, variable types and so on…

And:

import numpy as np

gives you access to NumPy-Python functions, such as np.array, np.linspace, etc

Cython internally handles this ambiguity so that the user does not need to use different names.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)