[SciPy-user] matrix mult operator
Robert Kern
robert.kern at gmail.com
Mon Jun 25 14:25:26 EDT 2007
dmitrey wrote:
> Robert Kern wrote:
>> dmitrey wrote:
>>
>>
>>> what about an operator, something like !* or *!
>>>
>>> def evalF(A,B,C, D):
>>> return A !* (B !* C).T !* D + C !* (D !* B).T * A
>>>
>>> it's much more readable.
>>> Of course, you can wait till Python will support unicode, but as for me
>>> I would prefere not to wait so long.
>>>
>> We do not control the Python language. We cannot add operators to the language.
>> FWIW, the support of Unicode identifiers that is coming in 3.0 still won't allow
>> you to define new operators.
>>
> Hmm... so it cannot be defined anything like
> numpy.array operator !* (numpy.array):
> return (matrix multiplication)
>
> But so many languages allow the trick! Even so ancient ones as (from my
> point of view) C/C++
No, neither C nor C++ does not let you define new operators. In C++, you can
overload the meaning of the existing set of operators for your new classes (same
with Python), but you cannot add new ones.
> It makes me very disappointed in Python, along with absence of 'switch'
> equivalent (I wonder why it's not implemented yet?..).
Because there isn't enough support for such a construct when we already have
if/elif and other ways of dispatching code. Guido asked the community and PyCon
2007, and there really wasn't much of a favorable response.
http://www.python.org/dev/peps/pep-3103/
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list