Matlab vs Python (was RE: Discussion: Introducing new operators f

tim.hochberg at ieee.org.bbs tim.hochberg at ieee.org.bbs
Mon Jul 17 16:40:04 EDT 2000


"Kevin Jacobs" <jacobs at darwin.epbi.cwru.edu> wrote in message

[SNIP]

> Silly idea 1:
>
>   Until add-on Python grammar modules are available, what about a
PyAlgebra
>   evaluator module.  For a precedent, see regular expressions.  The
>   difference is that linear-algebra syntax can be made too Python-like for
>   some tastes.
>
>   e.g.:
>
>   import PyAlgebra
>
>   PyAlgebra.run(r'A = (A .* B)\C')
>   e = PyAlgebra(r"D = A'*B")
>   e.run() # or e()
>
> Admittedly, its not perfect, nor optimally compact, but it is no longer
> encumbered by having to support the full Python grammar and is free to
> redefine as much as necessary.

Interestingly, an idea very similar to this was floated in the NumPy
community a couple years ago, but for entirely different reasons. The
motivation for this at the time was in order to support more efficient
matrix operations (eliminating intermediate results and such) and possibly
compiling the expression to native code. Digging through some of the NumPy
archives would probably reveal some interesting discussion of this possibly
not so silly idea.

-tim



More information about the Python-list mailing list