I'm trying to write a fast non copy interface for my python binding of a commercial image processing library. I implemented the new-style buffer api protocol which looks ok according to memoryview():
import hirsch as H
import numpy as np
w,h = 7,5
img = H.HImage.GenImageConst('byte',w,h)
m = memoryview(img)
print 'ndim shape=',m.ndim,m.shape
# -> 2 (5L, 7L)
What I don't understand is why numpy doesn't catch this interface?
a = np.array(img)
print 'ndim size shape=',a.ndim,a.size,a.shape
# -> 0 1 ()
Am I doing something wrong, or should I just resort to using the numpy array interface, which works, though it copies the data?
Note that I'm using python 2.7