[Numpy-discussion] NEP-18 comment

Marten van Kerkwijk m.h.vankerkwijk at gmail.com
Thu Mar 7 14:02:17 EST 2019

Hi Frédéric,

The problem with any environment type variable is that when you disable the
dispatch functionality, all other classes that rely on being able to
override a numpy function stop working as well, i.e., the behaviour of
everything from dask to astropy's Quantity would depend on that setting.

As another alternative, in any call where you *know* that the input is pure
ndarray, you can already call `np.<function>.__wrapped__(...)` to call the
original code. This is *not* guaranteed to remain in place between
versions, but obviously for cases that the speed really matters, one can
use it.

Personally, though, I think it would make most sense to try to ensure the
functions are as fast as possible including the dispatcher check, since
that benefits all. My sense is that for quite a number of numpy functions,
there is lower hanging fruit...

All the best,


On Thu, Mar 7, 2019 at 1:25 PM Frederic Bastien <fbastien at nvidia.com> wrote:

> I see speed changes vs behavior changes as different category of changes
> in my mind.
> I understand that now importing library can slow down NumPy for small
> arrays.
> But I have the impression you tell this can also give behavior change.
> I do not understand why this could happen. A pure numpy script, that you
> just import dask or other library without using them, would just cause a
> slowdown. Not a behavior change.
> Behavior change's start to happen only when you start to use the new
> library.
> Did I miss something?
> Frédéric
> -----Original Message-----
> From: NumPy-Discussion <numpy-discussion-bounces+fbastien=
> nvidia.com at python.org> On Behalf Of Stefan van der Walt
> Sent: Thursday, March 7, 2019 12:15 PM
> To: Discussion of Numerical Python <numpy-discussion at python.org>
> Cc: Matthew Rocklin <mrocklin at gmail.com>
> Subject: Re: [Numpy-discussion] NEP-18 comment
> Hi Sebastian, Frederic,
> On Thu, 07 Mar 2019 14:23:10 +0000, Frederic Bastien wrote:
> > I like your idea Sebastian. This way it is enabled only when needed and
> it is invisible to the user at the same time.
> >
> > Stefan, does it solve well enough the potential problem you raised?
> I don't think so.  This means that NumPy suddenly behaves differently when
> dask is imported, which again causes the problem mentioned earlier:
> that identical NumPy code could behave differently depending on library
> versions, imports, and the environment.
> That said, I think this is a better solution than an environment variable.
> Anyway, my opinion is just one of many: I'd like to hear what the other
> developers think.
> Best regards,
> Stéfan
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s) and
> may contain
> confidential information.  Any unauthorized review, use, disclosure or
> distribution
> is prohibited.  If you are not the intended recipient, please contact the
> sender by
> reply email and destroy all copies of the original message.
> -----------------------------------------------------------------------------------
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190307/9725ed1a/attachment-0001.html>

More information about the NumPy-Discussion mailing list