Hello, Currently, `zeros_like` is based `copyto` as opposed to `calloc`. This causes inconsistencies in the amount of time it takes to create an array with `zeros` + `shape` and `zeros_like` for large arrays. This was first raised https://github.com/numpy/numpy/issues/9909
It seems to me that a memory copy can be avoided by using `PyArray_NewFromDescr_int` in C. I propose creating a new C_API function `PyArray_NewZerosLikeArray` that behaves much like the `PyArray_NewLikeArray` with the exception that it calls `PyArray_NewFromDescr_int` instead of `PyArray_NewFromDescr` to initialize the array to zeros with calloc. An all C implementation of `zeros_like` is also possible by adapting the `empty_like` function. A draft implementation is viewable https://github.com/hmaarrfk/numpy/pull/2/files for those looking for more details about my proposed implementation. Thank you for considering. Mark
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion