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

Skip Montanaro skip at pobox.com
Wed Apr 3 10:55:25 EST 2002


    >> You're thinking of weave.inline().  I was talking about
    >> weave.blitz().  Reread the last statement in the text I quoted, then
    >> take a look here:
    >> 
    >> http://www.scipy.org/site_content/weave/tutorial.html#Blitz

    Jan> OK, I agree this is a nice piece of work. However, this is still
    Jan> limited to relatively simple, one line expressions. No way of
    Jan> adding more complex calculations (with ifs, loops,...).

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)

-- 
Skip Montanaro (skip at pobox.com - http://www.mojam.com/)





More information about the Python-list mailing list