I'm using Cython, to speed up my CPU-intensive Python program. However, my pythonic program makes excessive use of NumPy functions, and I'd want to reduce the amount of C-Python interaction. The code for this example is shown below.
import numpy as np
cimport numpy as cnp
def test_func():
cdef cnp.ndarray[cnp.float64_t, ndim=2] a
cdef unsigned int i, j
a = np.empty((100, 100), dtype=np.float64)
cdef double s = 0
for i in range(100):
for j in range(100):
s += a[i][j]**78 * 5
The code executes correctly, however the 'cython -a test.pyx' command highlights the lines 'a = np.empty((100, 100), dtype=np.float64)' and 's += a[i][j]**78 * 5'. Is there any additional type declaration I'm missing? Furthermore, the performance of this cython code and its Python version is nearly identical.