numpy 2.0.0
src/multiarray/convert.h File Reference

Go to the source code of this file.

Functions

NPY_NO_EXPORT int PyArray_FillWithZero (PyArrayObject *a)

Function Documentation

NPY_NO_EXPORT int PyArray_FillWithZero ( PyArrayObject a)
Fills an array with zeros.
Returns 0 on success, -1 on failure.

A zero-sized array needs no zeroing
If it's possible to do a simple memset, do so
Use an iterator to go through all the data
Because buffering is disabled in the iterator, the inner loop strides will be the same throughout the iteration loop. Thus, we can pass them to this function to take advantage of contiguous strides, etc.
By setting the src_dtype to NULL, we get a function which sets the destination to zeros.