[Numpy-discussion] slow numpy.clip ?

Tim Hochberg tim.hochberg at ieee.org
Tue Dec 19 20:15:17 CST 2006

Robert Kern wrote:
> Travis Oliphant wrote:
>> The problem with the copy=True keyword is that it would imply needing to 
>> expand the C-API for PyArray_Clip and should not be done until 1.1 IMHO.
> I don't think we have to change the signature of PyArray_Clip() at all.
> PyArray_Clip() takes an "out" argument. Currently, this is only set to something
> other than NULL if explicitly provided as a keyword "out=" argument to
> numpy.ndarray.clip(). All we have to do is modify the implementation of
> array_clip() to parse a "copy=" argument and set "out = self" before calling
> PyArray_Clip().
I admit to not following the clip discussion very closely, but if 
PyArray_Clip already supports 'out', why use a copy parameter at all? 
Why not just expose 'out' at the python level. This allows in place 
operations: "clip(m, m_min, m_max, out=m)", it is  more flexible than a 
copy argument and matches the interface of a whole pile of other functions.

My $0.02


More information about the Numpy-discussion mailing list