[Numpy-discussion] Resolving the associativity/precedence debate for @

Charles R Harris charlesr.harris at gmail.com
Tue Apr 1 11:13:26 EDT 2014

On Mon, Mar 24, 2014 at 6:33 PM, Nathaniel Smith <njs at pobox.com> wrote:

> On Mon, Mar 24, 2014 at 11:58 PM, Charles R Harris
> <charlesr.harris at gmail.com> wrote:
> > On Mon, Mar 24, 2014 at 5:56 PM, Nathaniel Smith <njs at pobox.com> wrote:
> >>
> >> On Sat, Mar 22, 2014 at 6:13 PM, Nathaniel Smith <njs at pobox.com> wrote:
> >> > After 88 emails we don't have a conclusion in the other thread (see
> >> > [1] for background). But we have to come to some conclusion or another
> >> > if we want @ to exist :-). So I'll summarize where the discussion
> >> > stands and let's see if we can find some way to resolve this.
> >>
> >> Response in this thread so far seems (AFAICT) to have pretty much
> >> converged on same-left.
> >>
> >> If you think that this would be terrible and there is some compelling
> >> argument against it, then please speak up! Otherwise, if no-one
> >> objects, then I'll go ahead in the next few days and put same-left
> >> into the PEP.
> >
> >
> > I think we should take a close look at broadcasting before deciding on
> the
> > precedence.
> Can you elaborate? Like what, concretely, do you think we need to do now?
Mostly I like to think of the '@' operators like commas in a function call
where each argument gets evaluated before the matrix multiplications take
place, so that would put it of lower precedence than '*', but still higher
than '+, -' . However, since most matrix expressions seem to be small it
may not matter much and the same result could be gotten with parenthesis.
But I do think it would make it easier to read and parse matrix expressions
as the '@' would serve as a natural divider. So 'A @ B*v' would be
equivalent to 'A @ (B*v)' and not '(A @B)*v'.

Hmm, now that I stare at it, it may actually be easier to simply read left
to right and use parenthesis when needed. So put me down as neutral at this
point and maybe trending towards equal precedence.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140401/ca7183dd/attachment.html>

More information about the NumPy-Discussion mailing list