[Pyrex] Math functions like exp, sin, cos, atan, etc.

Robert Kern robert.kern at gmail.com
Fri May 18 19:43:29 UTC 2007


stephen at theboulets.net wrote:
> Can someone tell me what the best way to use the functions in the math
> module in pyrex are? Say I'm going to use the "exp" function a million
> times in a loop, is "from math import exp" the best choice? Thanks.

If you are calling these on "cdef double" or "cdef float" variables rather than
Python objects, you are probably better off using the C functions in math.h instead.

cdef extern from "math.h":
    double exp(double x)

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Pyrex mailing list