A faster Python?, Python compiler, Dylan,...

Jan Kybic kybic at ieee.org
Wed Apr 3 11:10:26 EST 2002


The following message is a courtesy copy of an article
that has been posted to comp.lang.python as well.

> Not to belabor the point, but you can simply use Python's control
> structures:
> 
>     if today == "Monday":
>         expr = "a[1:-1,1:-1] =  (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]" \
>                               "+ b[1:-1,2:] + b[1:-1,:-2]) / 5."
>         weave.blitz(expr)

Yes, but you what if you want the structures 'inside' the loop? Example:

for i in xrange(1,a.shape[0]):
        if a[i,i]>30: a[i,i]+=a[i,i+1]
        else:          a[i,0]*=2.0

Not a particularly useful example, but one which could be much
accelerated by translating it (automatically) into C.
        
J.

-- 
-------------------------------------------------------------------------
Jan Kybic <kybic at ieee.org>      Robotvis, INRIA, Sophia-Antipolis, France
       or <Jan.Kybic at sophia.inria.fr>,tel. work +33 492 38 7589, fax 7845
                    http://www-sop.inria.fr/robotvis/personnel/Jan.Kybic/





More information about the Python-list mailing list