Re: Opaque structures and Extension Types
Robert Bradshaw <[email protected]> Wed, 14 May 2008 18:29:17 -0700
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
On May 14, 2008, at 4:47 PM, Greg Ewing wrote: > Roberto Cavada wrote: > >> My way of handling allocation and >> initialization of classes in C would require that __cinit__ of >> derived class would be not called at all, as for example >> Worker_create already handles the allocation and initialization of >> Person and Worker structures. > > I think you'll just have to initialise the struct in > __init__ rather than __cinit__, then you'll get > control over whether the base class __init__ is > called or not. > > It's not entirely safe, but it's about the best that > can be done until I do something about providing a > more Python-like __new__ method. One can also make a cdef method which the (only) baseclass __cinit__ calls, and simply override this for the subclass. One would want to do the same with deallocation as well. - Robert