Monte Carlo Method and pi

Peter Hansen peter at engcorp.com
Tue Jul 13 08:14:41 EDT 2004


Tim Hochberg wrote:

> beliavsky at aol.com wrote:
>> Does it make two calls to sin()? There is a performance hit for 'y = 
>> sin(x)*sin(x)'
>> when not using Psyco.
> 
> It appears that it does not make this optimization. I suppose that's not 
> suprising since my understanding is that Psyco generates really simple 
> machine code.

I suppose technically, since this is Python, two consecutive calls
to sin(x) could easily return different values...  It would be
insane to write code that did this, but the dynamic nature of
Python surely allows it and it's even possible such a dynamic
substitution would be of value (or even improve performance) in
some other situations.

-Peter



More information about the Python-list mailing list