performance problem in python 2.2

Fernando Perez fperez528 at yahoo.com
Fri Jul 26 18:41:09 EDT 2002


Paul Rubin wrote:

> 
> Also:
> 
> $p = 2**64;
> $c = $ARGV[0];
> $n = exp(-($c*$c) / (2*$p));
> print 1-$n, "\n";
> 
> should give a pretty close approximation faster than any of the
> iterative methods listed.
> 

cute.

I wasn't addressing the point of the existence of an analytic solution to the 
recursion (I haven't looked at your form, I'm assuming it's right), but 
simply that for a tight numerical loop, languages like perl and python are 
simply in a different class than C. Their inherent type flexibility (which 
means different things in the two, I know) simply prevents the possibility of 
the kind of optimizations that a compiled, statically typed language like C 
allows here.

The fact that one may spend a year's worth of cpu in computing an expression 
for which an analytic solution exists is orthogonal to the point I was making.

cheers,

f.



More information about the Python-list mailing list