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

Scott Dial scott+python-dev at scottdial.com
Fri Jul 25 04:46:24 CEST 2008


Greg Ewing wrote:

Scott Dial wrote:

Perhaps I'm nobody, but I think this would be ridiculous. Matrices are not native objects to the language. Why should that matter? We already have things like sum(), which operates on any sequence of numbers, without needing a special "array of numbers" data type.

I would argue that Python contains a "array of some_type" data type. That sum() performs a left-fold of add on the array is completely independent of them being numbers. In all fact, they could be any type that supports add/radd or even a mix of types. I do not believe "array of numbers" to be analogically equivalent to a "matrix of numbers". We have an "array of" type in Python, we do not have a "matrix of" type in Python. sum() is not an operator, it is a builtin; the suggestion was for there to be an operator, not a builtin. If you want to suggest there be a mmul() builtin, then perhaps there is a viable answer there, despite the lack of a "matrix of" type still.

I don't see why one shouldn't be able to perform matrix multiplication on a plausible representation of a matrix using the existing built-in sequence types.

What is "a plausible representation of a matrix"? Is it a list of lists? Row-major (m[1][2]) or column-major (m[2][1])? Is it a dictionary of tuple'd indices (m[1,2])? Also, You went on to talk about wanting to using numpy.array.

How does this not make it clear that there is not a case of TOOWTDI?

-Scott

-- Scott Dial scott at scottdial.com scodial at cs.indiana.edu



More information about the Python-Dev mailing list