[Numpy-discussion] is __array_ufunc__ ready for prime-time?
shoyer at gmail.com
Fri Oct 27 16:52:33 EDT 2017
We spent a *long time* sorting out the messy details of __array_ufunc__
, especially for handling interactions between different types, e.g.,
between numpy arrays, non-numpy array-like objects, builtin Python objects,
objects that override arithmetic to act in non-numpy-like ways, and of
course subclasses of all the above.
We hope that we have it right this time, but as we wrote in the NumPy 1.13
release notes "The API is provisional, we do not yet guarantee backward
compatibility as modifications may be made pending feedback." That said,
let's give it a try!
If any changes are necessary, I expect it would likely relate to how we
handle interactions between different types. That's where we spent the
majority of the design effort, but debate is a poor substitute for
experience. I would be very surprised if the basic cases (one argument or
two arguments of the same type) need any changes.
On Fri, Oct 27, 2017 at 12:39 PM William Sheffler <willsheffler at gmail.com>
> Right before 1.12, I arranged an API around an np.ndarray subclass, making
> use of __array_ufunc__ to customize behavior based on structured dtype (we
> come from c++ and really like operator overloading). Having seen
> __array_ufunc__ featured in Travis Oliphant's Guide to NumPy: 2nd Edition,
> I assumed this was the way to go. But it was removed in 1.12. Now that 1.13
> has reintroduced __array_ufunc__, can I now rely on its continued
> availability? I am considering using it as a base-level component in
> several libraries... is this a dangerous idea?
> William H. Sheffler Ph.D.
> Principal Engineer
> Institute for Protein Design
> University of Washington
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion