Hi,

I am having a problem getting the pure mode run (I think this used to
work before). Here is my cx.pyx file:

-------------
import cython

from numpy import array

#[email protected](x=cython.int)
def f(x):
    r = cython.declare(cython.int)
    i = cython.declare(cython.int)
    if x > 0:
        r = 1
        for i in range(1, x):
            r *= i
        return r
    else:
        return 0

def f_vectorized(a):
    return array([f(x) for x in a])
----------

and here is my cx.pxd file:
-----
cdef int f(int x)
-------

If I compile it:

$ cython cx.pyx
warning: /home/ondrej/repos/cython_test/cx.pyx:6:0: Overriding cdef
method with def method.


it doesn't build:

gcc -fPIC -O3 -I/usr/include/python2.6 -c -o cx.o cx.c
cx.c:196: warning: ‘__pyx_f_2cx_f’ used but never defined
gcc -fPIC -O3 -shared -o cx.so cx.o
/usr/bin/ld: cx.o: relocation R_X86_64_PC32 against undefined symbol
`__pyx_f_2cx_f' can not be used when making a shared object; recompile
with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [cx.so] Error 1


If I delete the pxd file, it works fine (but it's not a cdef function,
so it's slow).

In the wiki:

http://wiki.cython.org/pure

I can read:

Decorators

We have settled on @cython.cclass for the cdef class decorators, and
@cython.cfunc and @cython.ccall for cdef and cpdef functions
(respectively).
http://codespeak.net/pipermail/cython-dev/2008-November/002925.html



But the cfunc doesn't seem to be defined in the cython module.

So what is the way to create a pure python mode cdef functions?


I think I did something stupid above, I am trying to figure it out.

Thanks,
Ondrej
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to