On Wed, Apr 29, 2009 at 1:19 PM, Ondrej Certik <[email protected]> wrote:
> On Wed, Apr 29, 2009 at 12:37 PM, Robert Bradshaw
> <[email protected]> wrote:
>> On Apr 29, 2009, at 11:55 AM, Ondrej Certik wrote:
>>
>>> 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).
>>
>> Not sure--have you tried without the locals decorator in the Python
>> source? I hope this isn't a regression.
>
> Yes, as you can see, the locals is commented out. I'll try to bisect
> it to see which commit broke it.

Ok, so it never worked. I am a bit confused, because I thought the
pure python mode worked fine for me before.


In the current cython --- is there any way to keep a pure python code,
and create an accompanying pxd file that would annotate the cdef
functions and classes?

If not, how would you suggest this to be implemented? Ideally, the pxd
file would be either autogenerated, or created from the decorators
(maybe on the fly, or in the background). But as a first step, let's
write it by hand.
I was looking in the code - but I will need some time to dig into it
so that I can implemented the above, so I can do that after my school
finishes in couple weeks.

This summer we will fix assumptions in sympy as part of GSoC, so I
want to prepare the ground for using pure python mode for speeding up
the core, so that we don't have to maintain two codebases.

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

Reply via email to