[Pyrex] Subclassing Numeric arrays

Joachim Saul saul at gfz-potsdam.de
Mon May 9 08:33:14 CEST 2005


* George Sakkis [2005-05-08 21:00]:
> cdef class MyVector(ArrayType):
>     pass
>
> # seg fauls
> v = Vector((1,2))
>
> Can anyone show the simplest working subclass of PyArrayObject ?

To the best of my knowledge you can't subclass Numeric arrays in
Python and as Greg said, if not in Python you can't do so in Pyrex
either. This has been a subject of intense discussion amongst the
developers and users of Numeric, and apart from some "historical"
reasons there are some good technical reasons *not* to support
subclassing of Numeric arrays.

You may want to consider implementing MyVector as *containing* a
Numeric array rather that deriving it from the latter.

What makes me worry a bit is the segfault, though.

Cheers,
Joachim



More information about the Pyrex mailing list