[Pyrex] Subclassing - design question
Helmut Jarausch
jarausch at skynet.be
Wed Mar 8 14:46:36 CET 2006
Please note anywhere in the docs, that
the __new__ method of a class which
should be subclassable should have
only a single required parameter and
a placeholder for additional ones.
E.g. the corrected version the failing example
cdef class B:
cdef int Seen
def __new__(self,*dummy):
self.Seen=17
cdef class D(B):
def __new__(self,int DS):
self.Seen= DS
just works fine.
Helmut.
On 8 Mar, Helmut Jarausch wrote:
> Hi,
>
> given
>
> cdef class B:
> cdef int Seen
> def __new__(self):
> self.Seen=17
>
> cdef class D(B):
> def __new__(self,int DS):
> .....
>
> In Python the __init__ method of a base class must be called
> explicity (similarly to the base class initialization call
> in a C++ constructor)
> This is necessary since the base' __init__ can be called
> with different arguments.
>
> But in Pyrex the __new__ method of the base class is automatically
> called by the python runtime library, so Pyrex can only fill
> ONE possible call into the PyTypeObject table.
>
> Currently, function generate_new_function (if base_type:) of Nodes.py
> just copies it's own argument list. So, IHMO, Pyrex would need a
> new syntactic possiblity to let the user specify the arguments going
> to the base class.
>
> This shoe is too big for me (literal translation of a German saying)
>
> Helmut.
>
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
More information about the Pyrex
mailing list