[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] fast sqrt? and profiling



Marius Gedminas wrote:
On Wed, Jan 21, 2009 at 07:45:08AM -0800, Ian Mallett wrote:
math.hypot() is good for distance calculation.

I did some microbenchmarks a while ago, and math.hypot() was faster than
x**2 + y**2.  I was surprised.

Still, avoiding O(n**2) algorithms would be best.

Marius Gedminas
Out of curiousity, did you also try x*x + y*y? If it's using general purpose exponentiation routines I could see that being slower than a square root.

--Mike