Discussion: Introducing new operators for matrix computation

Bjorn Pettersen bjorn at roguewave.com
Thu Jul 13 15:18:37 EDT 2000


Huaiyu Zhu wrote:
> 
> We are at a crucial juncture concerning introduction of new operators into
> Python for matrix computation,
> 
> 1. Experiences with Matlab show that different operators for matrix and
>    elementwise operators are very important
> 
> 2. It is difficult to add .* and ./ as . is already a valid token.  It seems
>    that next candidate on the standard keyboard is @.
> 
> 3. Gregory Lielens has just implemented a patch that could parse additional
>    operators containing @
> 
>    a at b  is equivalent to a*b,  overloaded using __mmul__   and __rmmul__
>    a@/b                  a/b                    __mrdiv__  and __rmrdiv__
>    a/@b                  b/a                    __mldiv__  and __rmldiv__
>    a@@b                  a**b                   __mpow__   and __rmpow__
> 
>    He indicates similar constructions can be added easily.

It seems like you're trying to create a special purpose language here.
Ie. I don't see it as general enough to be worth putting into the core
unless you can come up with other use cases... Personally, I would much
prefer the ability to overload the relational operators (individually,
not through __cmp__).

-- bjorn




More information about the Python-list mailing list