[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power
Paul Moore
p.f.moore at gmail.com
Fri Mar 14 15:53:08 CET 2014
On 14 March 2014 14:13, Ethan Furman <ethan at stoneleaf.us> wrote:
>>>
>>> torient_inv.dot(tdof).dot(torient).dot(self.vertices[parent].meta['key']))
>>> (((torient_inv @ tdof) @ torient) @ self.vertices[parent].meta['key']
>>
>>
>> This doesn't look very readable to me - the operator saves you
>> a few parens in some situations, but as in the last example, it can
>> also require adding new ones.
>
>
> The difference being that grouping parens are easier to read and are less
> visual clutter than calling parens.
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.
Paul.
More information about the Python-ideas
mailing list