[Cython] PXD file for overriding math functions

Ian Bell ian.h.bell at gmail.com
Thu May 3 03:09:08 CEST 2012


Ok, I think I am missing something - I am a bit lost in the Cython jargon.
Here is where I stand, let me know where I am going wrong...   I compiled
with cython.py -a test.py, but it isn't working.  If I am completely not on
the right track, feel free to let me know :)

Ian

##### test.py (Pure python file) #####
from math import sin

def f(r):
    s=sin(r)
    return s

r=3.141592654/3.0
print f(r)

#### test.pxd #####
cimport cython
import cython

cimport math_override

@cython.locals(s=cython.
double)
cpdef f(double r)

#### math_override.pxd #####
cdef extern from "math.h":
    double sin_d "sin" (double x)
    float sin_f "sin" (float x)

cpdef inline double sin(double x):
    return sin_d(x)

cpdef inline float sin(float x):
    return sin_f(x)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20120503/6f935276/attachment.html>


More information about the cython-devel mailing list