[Numpy-discussion] New Operators in Python

Joe Harrington jh@physics.ucf....
Sun Mar 25 13:46:57 CDT 2007


I strongly agree with the need for different infix operators for
matrix and array multiplication.  In IDL, I have used both in the same
code.  IDL uses * for array and # for matrix (hey, # even *looks* like
a matrix, very intuitive).  It uses ## for right-multiply (why people
don't just M-t the variable names I don't know, though maybe people
who do more linear algebra than I can say).

There's an important justification that hasn't come up yet, and that
is advocacy.  Languages are good or not good depending on how readable
and writeable they are for various purposes.  LISP is a technically
very powerful language.  It was object-oriented a zillion years before
C++.  It had and has powerful proponents within CS, such as Stallman.

But, whenever CS people try to push LISP outside their ivory tower, it
gets trashed.  The LISP dialect Guile was written as the GNU project's
extension language and nobody used it.  Now projects like GIMP have
two extension languages, Guile and Python.  Why?  LISP is great for
analyzing the flow and structure of computer code, but LISP math does
not look like real math, which makes it very difficult and
counterintuitive to use for math or math-heavy topics like graphics.
It has little syntactic sugar to make common math tasks either quick
to write or easy to understand or verify, until you've retrained your
brain.  So, even though there are tons of technical people exposed to
LISP, nobody outside CS adopts it who doesn't have to.

On the other hand, Python, IDL, and Matlab are attractive to us mainly
because their syntaxes allow us to see the math, understand it on
inspection, and verify its correctness.  The math we write in these
languages looks as much like the math we do on paper as ASCII will
allow.  (Obviously, we also choose them because we don't like writing
loops and declaring variables.)

So, whenever I hear someone suggest using a functional syntax for a
concept that exists notationally, I cringe.  We're alienating a class
of users each time we do that.  Those are people who will never come
to Python.  There are extremes to which this argument cannot go - a
prime will never be a derivative because quotes are more important -
but I think that matrix multiplication is a no-brainer here.  We
should let the Python developers know we want it now and then follow
up with a syntax and implementation.

--jh--
Prof. Joseph Harrington
Department of Physics
MAP 420
University of Central Florida
Orlando, FL 32816-2385
(407) 823-3416 voice
(407) 823-5112 fax
(407) 823-2325 physics office
jh@physics.ucf.edu	(direct)
jh@alum.mit.edu		(permanent forwarding address, will work forever)


More information about the Numpy-discussion mailing list