python - Loop over a Numpy array with Cython -
let a , b 2 numpy.float arrays of length 1024, defined with
cdef numpy.ndarray cdef numpy.ndarray b i notice that:
cdef int in range(1024): b[i] += a[i] is considerably slower than:
b += why?
i need able loop manually on arrays.
the difference smaller if tell cython data type , number of dimensions a , b:
cdef numpy.ndarray[np.float64_t, ndim=1] a, b although difference smaller, won't beat b += a because using numpy's simd-boosted functions (which perform depending if cpu supports simd).
Comments
Post a Comment