2009/5/5 Stéfan van der Walt <[email protected]>:
>> You have to cimport to use C calls from another module. However, it
>> will still call __init__ with Python semantics. The more arguments
>> you pass (especially keyword arguments), the slower it'll get.
>
> I feel really silly that I can't get this working, but Cython
> complains that MyClass.pxd was not found, and then says:
>
> Name 'MyClass' not declared in module 'mymodule.myclass' (but it is
> defined in myclass.pxd and importable in Python as myclass.MyClass).
>
> It doesn't look like sage.rings.Integer has a .pxd file, so I'm not
> sure why mine is failing.
In case someone comes across this thread:
Sage *does* have .pxd files to the integer class, otherwise this wouldn't work.
The procedure is:
1. Define your class in myclass.pyx:
cdef class MyClass:
cdef test(self):
print "hello!"
2. Define a pxd "header" file:
cdef class MyClass:
cdef test(self)
3. Use *both* cimport and normal import:
from myclass cimport MyClass as MyClassT
from myclass import MyClass
cdef MyClassT m = MyClass()
m.test()
Hope that saves someone some time along the way.
Cheers
Stéfan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev