One of the nice things with making a Python wrapper to (clean) C++ code is that any data that lies evenly spaced contiguous in memory can be hooked into the numpy interface for advanced construction, slicing, dicing and lots of manipulation.
I've completed an interface for it for the Amount class now that I am happy with which then utilizes the protocol both for conversion to and from numpy.
To be able to do this, I needed:
- meta-information about the data like type, shape, padding, strides, etc.
- a pointer to the first element of the data.
For the most part, (1) is solvable on my end, at least for the structures that I have looked at so far. But (2) requires code changes.
What I need for Amount and proably a few classes is ways to get the pointer to the underlying data.
For the current implementation of Amount in amount.h I've just added:
Capacity* get_data(){
return elems.data();
}
And that is it. I can do my magic.
Does this sound like a reasonable plan?
One of the nice things with making a Python wrapper to (clean) C++ code is that any data that lies evenly spaced contiguous in memory can be hooked into the numpy interface for advanced construction, slicing, dicing and lots of manipulation.
I've completed an interface for it for the
Amountclass now that I am happy with which then utilizes the protocol both for conversion to and from numpy.To be able to do this, I needed:
For the most part, (1) is solvable on my end, at least for the structures that I have looked at so far. But (2) requires code changes.
What I need for
Amountand proably a few classes is ways to get the pointer to the underlying data.For the current implementation of
Amountinamount.hI've just added:And that is it. I can do my magic.
Does this sound like a reasonable plan?