futhark-pycffi icon indicating copy to clipboard operation
futhark-pycffi copied to clipboard

Expose store/restore functions in API

Open athas opened this issue 1 year ago • 2 comments

Not completely sure what that should look like.

athas avatar Apr 11 '23 06:04 athas

If no one else is working on this, I will make an attempt as I kind of need it. I'm not very used to working with python, but I think I could create a modified copy of the existing make_wrapper to make it work.

To make it a bit simpler, I think limiting the use of store to the case where futhark allocates the memory (passing NULL) is reasonable, as the user would otherwise be forced to use pointers directly. I suppose this could later be expanded by someone more familiar with python to accept an optional pointer argument.

Restore has fewer options, so it should be fairly straightforward.

Python appears to have more than one way of representing binary data, bytes and bytearray, and from what I've seen the primary difference is that bytes is immutable, whereas bytearray is mutable. Are there any reasons to prefer mutability in this case? I tend to prefer immutable data, but it is in principle less flexible. Perhaps the code can be made to accept both since they share methods(my statically typed brain finds this type of polymorphism pretty unintuitive)?

FluxusMagna avatar Apr 13 '23 15:04 FluxusMagna

Immutable bytes sound good to me.

I agree that it is best to let Futhark handle the allocation, but note that Python is still responsible for deallocation.

athas avatar Apr 13 '23 16:04 athas