How to support .NET class slicing using python syntax

Hailiang Shen

Dear all, as far as I know there is still no equivalent numpy lib available to IronPython. Please correct me if this is not the case anymore.


We have a few scripts that require numpy lib (using very basic functions e.g. numpy.array). To respond, I am planning to create a C# lib to support these numpy functions, to minimize the effort on the users (ideally just by updating from import numpy as np, and the rest of the code can be kept unchanged). One issue is to support slicing using python syntax, e.g. arr[1:3], where arr is a .NET class ndarray object. How can I modify ndarray class so its objects can be sliced in a pythonic way. Not sure implementing the special function __getitem__(self, index) will work since the index will be a slice object. A very simple example will work.


Also, what are other options you would use to mimic numpy lib?


Thanks for your inputs,




Join to automatically receive all group messages.