I'm using this to cleanup array in Cython
cdef void fill(DTYPE[:] ary):
cdef int i, size = len(ary)
for i in range(size): ary[i] = 0
is there a faster way ?
they seems to have it,cdef'd
cdef inline void zero(array self):
""" set all elements of array to zero. """
memset(self.data.as_chars, 0, Py_SIZE(self) * self.ob_descr.itemsize)
generated code :
cdef array.array rows
array.zero(rows)
__pyx_f_7cpython_5array_zero(__pyx_v_rows);
but if :
cdef float[::1] rows
@DavidW example generates a cleaner version i.e. for-loop
summarized it here and added some more tricks