[Numpy-discussion] code review request: masked dtype transfers

Mark Wiebe mwwiebe at gmail.com
Sat Jul 9 01:06:34 EDT 2011


On Fri, Jul 8, 2011 at 10:04 PM, Eric Firing <efiring at hawaii.edu> wrote:

> On 07/08/2011 01:31 PM, Mark Wiebe wrote:
> > I've just made pull request 105:
> >
> > https://github.com/numpy/numpy/pull/105
> >
> > This adds public API PyArray_MaskedCopyInto and PyArray_MaskedMoveInto,
> > which behave analogously to the corresponding unmasked functions. To
> > expose this with a reasonable interface, I added a function np.copyto,
> > which takes a 'where=' parameter just like the element-wise ufuncs.
> >
> > One thing which needs discussion is that I've flagged 'putmask' and
> > PyArray_PutMask as deprecated, because 'copyto' PyArray_MaskedMoveInto
> > handle what those functions do but in a more flexible fashion. If there
> > are any objections to deprecating 'putmask' and PyArray_PutMask, please
> > speak up!
>
> Mark,
>
> Looks good!  Some quick tests with large and small arrays show copyto is
> faster than putmask when the source is an array and only a bit slower
> when the source is a scalar.
>

With a bit of effort into performance optimization, it can probably be
faster in the scalar cases as well. Currently, the masked case is always a
function which calls the unmasked inner loop for the values that are
unmasked. A faster way would be to create inner loops that handle the mask
directly.

-Mark


>
> Eric
>
> >
> > Thanks,
> > Mark
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110709/a67c26a0/attachment.html>


More information about the NumPy-Discussion mailing list