[Pyrex] Extension type initialization
khinsen at cea.fr
khinsen at cea.fr
Tue Mar 15 19:06:57 CET 2005
On Mar 14, 2005, at 23:44, Greg Ewing wrote:
> It's by design. It has to be a Python function, because
> it's callable from Python and there is no C slot for it
> in the type structure.
OK.
> What you can do is leave the object with no __init__ method
> and a __new__ that requires no arguments, and have another
> C method that you call afterwards to initialise it.
OK, that looks doable.
> Hpwever, if you do that, you'll have to be prepared to deal
> with the possibility that Python code will instantiate the
> type without the C method getting called.
I would need a real __init__ for Python access anyway, so I would hide
the basic C type and propose a subclass with an __init__ method to the
outside world.
I'll let you know if that works as I expect.
Thanks,
Konrad.
--
---------------------------------------------------------------------
Konrad Hinsen
Laboratoire Léon Brillouin, CEA Saclay,
91191 Gif-sur-Yvette Cedex, France
Tel.: +33-1 69 08 79 25
Fax: +33-1 69 08 82 61
E-Mail: khinsen at cea.fr
---------------------------------------------------------------------
More information about the Pyrex
mailing list