Matlab vs Python (was RE: Discussion: Introducing new operators for matrix computation)

Kevin Jacobs jacobs at darwin.epbi.cwru.edu
Tue Jul 18 07:56:53 EDT 2000


Huaiyu Zhu <hzhu at localhost.localdomain> wrote:
> result = e(r'transform * get_data_from(webobject(url))')

> or even using "http:..." in place of url?  Eventually, wouldn't the
> e(r'...') be able to parse the whole python grammer?

Not really.  From what I've seen, the Python expression syntax is
significantly simpler than the full grammar.  At least, its much simpler to
parse.

> One of my biggest gripe about matlab is it forces me to treat strings as
> part of matrix.  Now you are asking me to treat matrix as part of string.
> :-)

Not matrices, just matrix expressions.  Maybe this isn't such a big deal
for me since I grew up with LISP and Scheme.


> There are proposals for using @/ and /@ for two directions of division, or
> using % for left division.  I'm comfortable with the current solve(a,b), or
> maybe a shorter sol(a,b) but am open to any suggestions.

I have no problem with adding syntax for defining new operators.  In fact, I
think that Standard ML allows just that.  I know I've seen a proposal
something like this posted already, but lets consider a builtin like:

add_infix_operator('.*', default_binary_element_multiply_evaluator,
                   '__relement_multiply__', # Right associative class member
                   '__lelement_multiply__') # Left associative class member

where the default evaluator is called if the right or left associative
member evaluators are not specified on the operand classes.  Such a scheme
would be sufficient if all the proposed linear-algebra syntax used valid
operators.  It should be possible to augment the Python grammar to support
this, though its certainly not trivial.

-Kevin


-- 
----------->  Kevin Jacobs  <-----------|------->  (216) 778-8211  <--------
S.A.G.E. Project Technical Coordinator  | Department of Epidemiology
  & System Administrator                |   & Biostatistics
Internet E-mail: jacobs at darwin.cwru.edu | Case Western Reserve University
----------------------------------------------------------------------------



More information about the Python-list mailing list