[Numpy-discussion] Should non ufunc numpy functions behave like ufunc regarding casting to output argument ?
rlw at stsci.edu
Tue Jan 16 07:00:42 CST 2007
On Jan 15, 2007, at 10:41 PM, David Cournapeau wrote:
> Concerning the point of avoiding allocating new storage, I am a bit
> suspicious: if the types do not match, and the casting is done at the
> end, then it means all internal computation will be done is whatever
> type is chosen by the function (I am using PyArray_CommonType for
> and the cast done at the end, meaning new storage.
Presumably you should do what ufuncs do: divide the computation up
into blocks when the array is big. If a cast is required then you do
the computation for each block, allocating new storage for that
block. Then you do the cast for the block and copy it to the output
That way you only have to allocate enough new storage for a single
block, which is (potentially) much smaller than the whole array.
More information about the Numpy-discussion