[Python-ideas] Infix matrix-multiply, but not general infix operators?

Jared Grubb jared.grubb at gmail.com
Thu Mar 20 08:41:40 CET 2014


A couple months back, Andrew Barnet brought up the idea of adding a way to apply functions in an infix style. It really didnt gain much traction. (Subject line "Infix Functions")

Nathaniel Smith has just proposed a PEP to add an infix matrix multiply operator, and everyone seems to love it.

I honestly am surprised at the difference in reaction. Why are we so quick to add a single-purpose punctuation mark, but reject a named infix operator that works for many general cases? Is the matrix-multiply use case so special?

I dont oppose the PEP, and I dont mean to derail it. And I know there was quite a bit of discussion on Andrew's email. But I cant help feel that Andrew's idea didnt get the appreciation it should. (But hey, I'm biased because I like the idea :)) 

Jared

QUICK SUMMARY OF ANDREW'S EMAIL:
(Not a proposal for syntax or naming)

    m `cross` n
    m `dot` n

    a `Pair` b
    a `Tree` (b `Tree` c `Tree` d) `Tree` e

And of course the matrix multiply (and matrix div that was briefly discussed) are implementable too:

    m `mmul` n
    m `mdiv` n



More information about the Python-ideas mailing list