Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation)
Paul Prescod
paul at prescod.net
Tue Jul 18 17:01:12 EDT 2000
John Lull wrote:
>
> ...An element-wise matrix, however, would have exactly the
> same data as the original matrix, it just has a lot of the *methods*
> replaced.
So? That's easy.
> To make this work for derived classes, you have to either
> add a level of indirection to all the standard operator methods, or
> prohibit overriding the standard operator methods.
Either option is easy. Are we really that concerned about matrix
subclasses?
> This would provide a way of adding a reasonable variety of
> domain-specific operators to *any* class with very little impact on
> the language, zero runtime penalty, and obvious & correct behaviour
> when creating derived classes. It would not break any existing code
> and should be very simple to implement.
This is basically the original proposal slightly reworded. The problem
is that alot of people think that adding operators without predefined,
cross-module semantic is un-pythonic. Python allows operator overloading
but the meaning behind the syntaxes are always well-defined. "+" is for
addition-like things. "*" is for multiplication-like things. [] for
indexing-like things, "." for attribute-like things and so forth.
--
Paul Prescod - Not encumbered by corporate consensus
Just how compassionate can a Republican get before he has to leave the
GOP and join Vegans for Global Justice? ... One moment, George W. Bush
is holding a get-to-know-you meeting with a bunch of gay Republicans.
The next he is holding forth on education or the environment ... It is
enough to make a red-blooded conservative choke on his spotted-owl
drumstick. - April 29th, Economist
More information about the Python-list
mailing list