New Array Type Considerations
Requirements
- libecs::array (or whatever classname/alias) must be compatible in memory addressing with the standard C-array. this makes it easy to interoperate with python-numpy and other numerical packages like GSL.
- libecs::array must have a straightforward and convenient API, as it will be used from everywhere including DM-developers.
- access from the Python frontend may need some thought.
- zero-copy is preferable when a libecs::array is accessed from Python. maybe we can restrict accesses from frontend read-only. we can provide other functions as the main read-only ones for mutation. as I understand, the current numpy C-API doesn't allow constructing a new numpy.array by borrowing a pointer. for this we might need to extend numpy or write some new code.
- one strategy is to contain arrays within C++ and not fully expose into Python. two of possible implementations are; to define a view class, or to define only element-wise access functions.
Download in other formats: