[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power

Zachary Ware zachary.ware+pyideas at gmail.com
Fri Mar 14 16:46:25 CET 2014


Disclaimer: I am not a numpy (or similar) user and have only skimmed
this thread.  If I've simply missed something big, I can be safely
ignored :)

On Fri, Mar 14, 2014 at 9:53 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> Personally, my biggest problem with all of these is that the @ sign is
> a bit too big and bulky, so it's visually jarring.
>
> But:
>
> 1. As the PEP mentions, there aren't many options available.
> 2. I trust the scientific community to choose something that they are
> comfortable with (I'm only an interested outsider).
> 3. Ultimately, this is just bikeshedding.
>
> One genuine question though - when the PEP was developed, were
> multi-character operators like .* or <*> considered? A "rejected
> alternative operator symbols" would be a useful addition to the PEP
> (although it'd rob all us non-experts of the opportunity to bikeshed
> :-))
>
> On a related note, the @@ operator is visually dreadful (far too
> heavy). While I see the */** analogy, and I appreciate that there's
> few good options, I'd definitely like to see some evidence that it's
> "the best of a bad lot" in the PEP.

I agree with Paul, @/@@ just look scary as operators.  Here's a few
multi-character options I've come up with that I would like to see
shot down in flames before @/@@ are added to Python:

>< (for multiplication, not sure about exponentiation.  I only like it because it's the shortest thing I've come up with that looks somewhat like multiplication)
[*] / [**] ([] make me think 'matrix', but this might be confusing to
the parser)
|*| / |**| (pretty close to [], shouldn't confuse the parser)

The downside is that the inplace version of matrix exponentiation
would be a 5 character operator ([**]=), which I will freely admit is
not appealing, but it *looks* quite a lot nicer to me than "@@=" does.

-- 
Zach


More information about the Python-ideas mailing list