Storing a C pointer in a Python class instance

sturlamolden sturlamolden at yahoo.no
Wed Sep 30 17:52:15 EDT 2009


On 30 Sep, 19:03, Carl Banks <pavlovevide... at gmail.com> wrote:

> Second, CObjects do not have a __del__ method.  They call the supplied
> constructor from the type's tp_dealloc slot.  Use of the tp_dealloc
> slot does not, by itself, prevent cyclic GC.
>
> Bottom line is, the CObject's deallocator is as reliable as a custom
> type's tp_dealloc.

You are right. I did not look at the PyCObject_* API close enough.

I thought of wrapping the CObject with a Python class, and calling the
destructor from __del__. That would be less reliable.

S.M.









More information about the Python-list mailing list