Von: "Nathaniel Smith" <n...@pobox.com>
An: "Discussion of Numerical Python" <numpy-discussion@scipy.org>
Betreff: Re: [Numpy-discussion] Silent Broadcasting considered harmful
On 8 Feb 2015 13:04, "Stefan Reiterer" <dom...@gmx.net> wrote:
>
> So I suggest that the best would be to throw warnings when arrays get Broadcasted like
> Octave do. Python warnings can be catched and handled, that would be a great benefit.
>
> Another idea would to provide warning levels for braodcasting, e.g
> 0 = Never, 1=Warn once, 2=Warn always, 3 = Forbid aka throw exception,
> with 0 as default.
> This would avoid breaking other code, and give the user some control over braodcasting.
Unfortunately adding warnings is a non-starter for technical reasons, even before we get into the more subjective debate about ideal API design: issuing a warning is extremely slow (relative to typical array operations), EVEN IF the warning is disabled. (By the time you can figure out it's disabled, it's too late.) So this would cause massive slowdowns in existing code.
Note also that in numpy, even simple expressions like '2 * arr' rely on broadcasting. Do you really want warnings for all these cases?
-n
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion