Right, it's obviously possible to do directly, but then I have to
think about how to reimplement all the stuff that cython normally does
for me -- bounds checking (or not), handling multi-dimensional
indices, etc. So I was hoping for something more terse. Maybe like
def get_voidptr(void [:] a, Py_ssize_t i):
return &a[i]
but of course this doesn't work. (BTW the np.ndarray[void] version of
this hits an assertion error in the cython compiler rather than
producing a real error message.)
Since the item size is variable, I can't statically declare a Cython
struct to use. I guess the problem is that Cython wants to check that
the ndarray's dtype is compatible with whatever C type it's using, and
to do that it needs to be able to introspect that C type? I can't see
any other reason why this *couldn't* work, just going ahead and
generating C code for the above function in the ordinary way should
basically just DTRT.
-n