[Numpy-discussion] Should non ufunc numpy functions behave like ufunc regarding casting to output argument ?

David Cournapeau cournape at gmail.com
Tue Jan 16 09:09:31 CST 2007


On 1/16/07, Rick White <rlw at stsci.edu> wrote:
> 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
> > that),
> > 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
> array.
>
Well, at that point, why not making clip a ufunc, then... I was
already wondering about that, but I don't know much about ufunc on C
side.

David


More information about the Numpy-discussion mailing list