[Python-Dev] Infix operators (original) (raw)

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Jul 24 04:05:01 CEST 2008


Sebastien Loisel wrote:

Essentially, in almost all applications, inv(A) is entirely wrong. You can ask any numerical analyst who works with large problems, and they will confirm it. One of the main reason is that, even if A is sparse, inv(A) is full.

This argues for a function such as solve(A, b). It doesn't argue for an infix operator.

But why not put in this infix possibility?

Guido is on record as opposing any kind of macros or other "extensible syntax", and this probably comes under the same heading.

Besides which there are technical difficulties, such as how the parser is supposed to know the precedence of these user-defined operators.

To address your original problem, I believe that numpy comes with a matrix type that defines * as matrix multiplication. That's the usual Python solution to these kinds of things -- rather than invent a new operator, invent a new type that behaves the way you want.

-- Greg



More information about the Python-Dev mailing list