Hi Jeroen!

On 31 Jul., 02:30, Robert Bradshaw <[email protected]>
wrote:
> ...
> > In file A.pyx, I have
> > cdef MyClass myobj
> > cdef class MyClass:
> >    [...]
>
> > In file A.pxd, I have
> > cdef class MyClass:
> >    [...]
>
> > In file B.pyx, I would like to access "myobj" from A.pyx, but how?
>
> You can't access cdef members of Cython modules from other modules
> (yet). Here you'd probably want to make an accessors method in A.
> Either that our you could not declare it as a MyClass (but in that
> case it'd be just a normal Python object).

Would this work?

in A.pyx:
myobj_py = MyClass(...)
cdef MyClass myobj = myobj_py
cdef class MyClass ...

in A.pxd
cdef class MyClass:
    [...]

in B.pyx:
from A import myobj_py
from A cimport MyClass
cdef MyClass myobj = myobj_py

In that way, you have the cdef object myobj in both A and B

Cheers,
Simon

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to