dealloc function in python extend c module

Shen, Yu-Teh shenyute at
Thu Jul 2 02:11:54 EDT 2009

I create my extend type something like
And my type has a member which is a pointer point to my allocate
memory ( no ref count).
typedef struct {
    /* Type-specific fields go here. */
    mytype *p;
} noddy_NoddyObject;

And i write dealloc function like this:
static void
Noddy_dealloc(Noddy* self)
    delete p;

And I found it's strange that it didn't call dealloc when there is no

a = Noddy()
b = a
del a
del b
# i think there is no ref to the object, and it should call dealloc
but it didn't call!!!

could anyone tell me what happened?

Thanks a lot!!

More information about the Python-list mailing list