[Numpy-discussion] Subclassing ndarray in C: getitem ?
Wed Jul 28 18:52:32 CDT 2010
Wed, 28 Jul 2010 18:43:30 -0400, Pierre GM wrote:
> Mmh. I did create a PyMappingMethod structure called MyArray_as_mapping,
> and MyArray_as_mapping.mp_subscript points to the function that I want
> to use. However, I'd like the MyArray_as_mapping.length and
> MyArray.mp_ass_subscript to point to their PyArray equivalent. I was
> hoping to do something like MyArray_as_mapping.length =
> array_as_mapping.length but I don't know how to import array_as_mapping.
Maybe you can leave them NULL? I don't remember if they are inherited.
> I also tried to do
> MyArray_as_mapping.length = &PyArray_Type->tp_as_mapping->length but it
> doesn't work... And that's where I'm stuck...
How it fails?
Note that you probably need to call import_array() first before assigning
the function pointers.
More information about the NumPy-Discussion