A faster Python?, Python compiler, Dylan,...
Jan Kybic
kybic at ieee.org
Thu Apr 4 02:54:44 EST 2002
> For this particular example, weave.inline is a perfect solution. The C++ code
> is pretty readable:
>
> from scipy import *
>
> def foo(a):
> code = """
> for (int i = 0; i < _Na(0);i++) {
> if (a(i,i) > 30) a(i,i) += a(i,i+1);
> else a(i,0) *= 2.0; }
> """
> weave.inline(code,'a',compiler='gcc',
> type_converters = weave.converters.blitz)
>
> a = rand(3,3)*60
> print 'before:', a
> foo(a)
> print 'after:', a
>
Great, I am becoming even more impressed. However, the main criticism
remains: You have to code your function twice, first in Python for
prototyping, then in C. But I agree that weave saves you a lot of
work.
> The place where weave breaks down is when you have a lot of calls within the
> loop to Python functions. This is a common problem, and the only way around it
> is to have something that compiles the Python to C or assembly or something.
Indeed.
> That is what Psycho does. weave may also do something similar in the forseeable
> future. Pat Miller is integrating some work similar to Psycho into weave that
> converts Python to C on the fly using type inferencing and then uses weave to
> build the extension module. Several of the aims are different than psycho, but
> the concepts are similar.
Great. I will stay tuned.
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