Storing a C pointer in a Python class instance

Carl Banks pavlovevidence at
Tue Sep 29 19:11:04 CEST 2009

On Sep 29, 9:42 am, sturlamolden <sturlamol... at> wrote:
> You can use PyCObject, or write your own extension type that wraps the
> pointer (very easy to to with Cython or Pyrex). The advantage of using
> an extension type is you have a guarantee from Python on the
> deallocator method being called (cdef __dealloc__ in Cython).

CObjects can be passed a C function as a deallocator; this should work
as reliably as a custom class deallocator.

Carl Banks

More information about the Python-list mailing list