[Pyrex] Opaque structures and Extension Types

Greg Ewing greg.ewing at canterbury.ac.nz
Thu May 15 10:27:40 CEST 2008


Roberto Cavada wrote:
> Now if I need to use __init__ I wonder what those 'some 
> circumstances' are exactly, especially which are the cases when 
> __init__ is not called at all.

It's not called when Python code calls the class's
__new__ method directly instead of calling the
class itself.

Another situation is unpickling, although that's
not likely to bother you, since extension types
aren't pickleable anyway unless you take steps to
enable it.

> For deallocation, I've thought I can rely on __dealloc__ in root 
> classes and exploit virtual destructors in my C structures.

Yes, you should always be able to rely on __dealloc__
getting called, and C method calls from it should work
as expected.

-- 
Greg



More information about the Pyrex mailing list