On Jun 5, 2009, at 12:42 PM, Matthew Bromberg wrote:

> I am not entirely clear how memory management works in cython for
> extension classes and their attributes/members.
>
> I have a class in a .pxd file defined like,
>
> cdef class rmat :
>      """  Real matrix class binds to both vsipl and numpy ndarray.
>      The ndarray object is returned via getarr.  The array is bound
>      back to vsipl via admit """
>      cdef vsip_mview_f *vm
>      # this should be allowed but currently isn't
>      # cdef np.ndarray[np.float32_t, ndim=2] arr
>      # cdef vsip_block_f *block
>      cdef object arr
>      cpdef rmat parent
>   ....

There's no such thing as a cpdef attribute, just cdef, cpdef only  
makes sense for functions.

> Question 1,  are references to an rmat object reference counted and
> garbage collected?
> So far it seems like they are.
>
> Question 2)  Are extension class members set to  other  extension
> classes or python objects,  such as  arr and parent  reference  
> counted?

Yes, anything that is an object (including subclasses thereof) is  
reference counted. You should never have to worry about reference  
counts unless you're casting objects to or from pointer types.

- Robert

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

Reply via email to