[Numpy-discussion] [help needed] associativity and precedence of '@'

Charles R Harris charlesr.harris at gmail.com
Sat Mar 15 12:40:00 EDT 2014


On Sat, Mar 15, 2014 at 9:58 AM, Robert Kern <robert.kern at gmail.com> wrote:

> On Sat, Mar 15, 2014 at 2:49 PM, Charles R Harris
> <charlesr.harris at gmail.com> wrote:
> >
> > I favor the weak right option.
> >
> > 1) Giving '*' higher precedence than `@` makes it easier, to my mind, to
> > parse out what is going to happen: all the element-wise multiplications,
> > followed by the matrix operations. I'd probably still use parenthesis for
> > clarity.
>
> It seems to me that 'tight' gives the same benefit. Any reasoning for
> the preference of 'weak' over 'tight'?
>
>
Two other reasons come to mind. First, '*' is right associative, so I think
it is nicer to first view the expression as parsed into blocks separated by
'@', which act somewhat like parenthesis at that point, and then evaluate
the blocks. Second, and somewhat weaker, it might make it easier to track
how arrays are broadcast.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140315/33b37d82/attachment.html>


More information about the NumPy-Discussion mailing list