On Mon, Mar 17, 2014 at 3:48 PM, Nathaniel Smith <n...@pobox.com> wrote:
> On Sat, Mar 15, 2014 at 7:01 PM, Alexander Belopolsky <ndar...@mac.com> wrote:

>> One more question that I think should be answered by the PEP and may
>> influence the associativity decision is what happens if in an A @ B @ C
>> expression, each operand has its own type that defines __matmul__ and
>> __rmatmul__?  For example, A can be an ndarray, B a sympy expression and C a
>> pyoperator.
>
> The general rule in Python is that in a binary operation A # B, then
> first we try A.__special__, and if that doesn't exist or it returns
> NotImplemented, then we try B.__rspecial__. (The exception is that if
> B.__class__ is a proper subclass of A.__class__, then we do it in the
> reverse order.)

Assuming that all combinations are possible and give no error:

  A @ B @ C == A.__matmul__(B.__matmul__(C))  # right

  A @ B @ C == A.__matmul__(B).__matmul__(C)  # left

Did you want to specify which permutations of X.__matmul__(Y) return
NotImplemented?

-- 
Robert Kern
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to