Am 23.09.16 um 21:50 schrieb Irmen de Jong:
The problem boiled down to a performance issue in window's 32 bits 
implementation of the
hypot() function   (which abs(z) uses when z is a complex number type).
The 64 bits windows crt lib version is much faster (on par with what is to be 
expected
from the linux or osx version), but  unfortunately there's no 64 bits pypy
implementation for windows.
Replacing abs(z) by sqrt(r*r+i*i) avoids the problem and is even faster still.

Interesting! Now beware that a "real" hypot function does approximately the following:

def myhypot(r, i):
    if abs(r)>abs(i):
      c = i/r
      return abs(r)*sqrt(1+c*c)
    else:
      if i==0:
        return 0.0
      else:
        c=r/i
        return abs(i)*sqrt(1+c*c)


it can well be, that the old 32bit MSVCRT does simply that, which requires some floating point ops, whereas the more modern 64bit lib uses hand-tuned SSE to perform the equivalent. Just for fun, you could try this hypot to see how it performs.


        Christian
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to