[Numpy-discussion] is __array_ufunc__ ready for prime-time?
ben.v.root at gmail.com
Thu Nov 2 17:09:33 EDT 2017
Duck typing is great and all for classes that implement some or all of the
ndarray interface.... but remember what the main reason for asarray() and
asanyarray(): to automatically promote lists and tuples and other
"array-likes" to ndarrays. Ignoring the use-case of lists of lists is
problematic at best.
On Thu, Nov 2, 2017 at 5:05 PM, Marten van Kerkwijk <
m.h.vankerkwijk at gmail.com> wrote:
> My 2¢ here is that all code should feel free to assume certain type of
> input, as long as it is documented properly, but there is no reason to
> enforce that by, e.g., putting `asarray` everywhere. Then, for some
> pieces ducktypes and subclasses will just work like magic, and uses
> you might never have foreseen become possible. For others, whoever
> wants to use them has to do work (and up to a package maintainers to
> decide whether or not to accept PRs that implement hooks, etc.)
> I do see the argument that this way one becomes constrained in the
> internal implementation, as a change may break an outward-looking
> function, but while at times this may be inconvenient, in my
> experience at others it may just make one realize an even better
> implementation is possible. But then, I really like duck-typing...
> -- Marten
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion