Storing a C pointer in a Python class instance
Carl Banks
pavlovevidence at gmail.com
Wed Sep 30 13:03:13 EDT 2009
On Sep 29, 11:16 am, sturlamolden <sturlamol... at yahoo.no> wrote:
> On 29 Sep, 19:11, Carl Banks <pavlovevide... at gmail.com> wrote:
>
> > CObjects can be passed a C function as a deallocator; this should work
> > as reliably as a custom class deallocator.
>
> Except that __del__ prevents cyclic GC.
You are mistaken on two counts.
First of all, a CObject is not a container. It can't prevent cyclic
GC because it's never a part of a cycle.
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.
Carl Banks
More information about the Python-list
mailing list