numpy.array.tostring doesn\'t seem to preserve information about matrix dimensions (see this question), requiring the user to issue a call to numpy.array.
Msgpack has the best serialization performance: http://www.benfrederickson.com/dont-pickle-your-data/
Use msgpack-numpy. See https://github.com/lebedov/msgpack-numpy
Install it:
pip install msgpack-numpy
Then:
import msgpack
import msgpack_numpy as m
import numpy as np
x = np.random.rand(5)
x_enc = msgpack.packb(x, default=m.encode)
x_rec = msgpack.unpackb(x_enc, object_hook=m.decode)