Indeed, .tostring only returns the original data. This means that you also need to submit the form and type of the array if they are not known on the other hand.
It may be easier to serialize the array using Pickle:
import numpy as np from cPickle import dumps, loads x = np.array([[1, 2],[3, 4]], np.uint8) print loads(dumps(x))
Although for very small arrays, the overhead size can be significant:
print len(x.tostring()), len(dumps(x))
For more information on using Pickle, see here.
user2379410
source share