Stéfan van der Walt wrote:
> 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()

Note that this will generate unnecessary type checks in the code as Cython
cannot know that both types are identical. There should be no reason to
import both, just stick with the cimport.

Stefan

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

Reply via email to