[Numpy-discussion] slow numpy.clip ?

Robert Kern robert.kern at gmail.com
Tue Dec 19 20:36:05 CST 2006

Tim Hochberg wrote:
> 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.

It's already exposed. I just didn't know that before I proposed copy=True (and
when I learned it, my brain was already stuck in that mode).

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the Numpy-discussion mailing list