[Numpy-discussion] A zeros_like implementation based on calloc instead of copyto
mark.harfouche at gmail.com
Mon Oct 15 08:44:01 EDT 2018
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
I propose creating a new C_API function `PyArray_NewZerosLikeArray` that
behaves much like the `PyArray_NewLikeArray` with the exception that it
`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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion