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

Huaiyu Zhu huaiyu_zhu at yahoo.com
Mon Jul 17 20:42:44 EDT 2000


On Mon, 17 Jul 2000, Bjorn Pettersen wrote:

> I think you hit the crux of the problem. You want to add syntax that is
> only useful in one domain, and that is too extreme.

I don't buy this dichotomy here: either it is every domain, or it is only
one (meaning limited) domain.  I don't even know if there is a general
meaninful rule to count application domains in integers. 

I haven't yet heard much comment about either

a = ["Alice", "Bob"]
b = " is "
c = ["a girl", "a boy"]
d = a .+ b .+ c

or ESR's comment about using .& and .| for lattice algebra, which I suppose
include union and intersection of sets, among other things.  

What about the example of plotting graphics of server statistics on the web?
Which domain is it: numerical processing or text processing or visual arts?

I don't see such arguments as any different from the claim that string
literals are sintactic sugar for the single domain of text processing only
(web and re and so on being subdomains).  Since by such definition text
processing is a very large domain I do want string literals even just for
this only domain, even if it does not include everything.

A more reasonable threshold along these lines would be "sufficiently wide",
but I don't see we are going to get clear consensus on that point so I won't
continue on this topic.

> Why don't you create a preprocessor that converts
> 
>   a .* b
> 
> into
> 
>   elementWiseMultiply(a,b)
> 
> and create an appropriate suffix for your matlab/python files (mpy?)
> It's a pretty easy thing to do, and sounds much more appropriate in this
> situation.

This could work if there is a hook so that 

import mymodule

would automatically run

preprocessor < mymodule.mpy > mymodule.py

anywhere in the path.  It should do this after examining the timestamp just
like current import does.  Otherwise after a few surprises people would keep
.py instead of .mpy so it is just a helper for writing, but not useful for
extending or maintaining code,

On the other hand, if there is an introspective module that affects how the
parser reads the rest of the file it would be eminently useful.

Huaiyu





More information about the Python-list mailing list