title: fastest method to dump numpy array into string
body: <p>I need to organized a data file with chunks of named data. Data is NUMPY arrays. But I don't want to use numpy.save or numpy.savez function, because in some cases, data have to be sent on a server over a pipe or other interface. So I want to dump numpy array into memory, zip it, and then, send it into a server.</p>
  
  <p>I've tried simple pickle, like this:</p>
  
  <pre><code>try:
      import cPickle as pkl
  except:
      import pickle as pkl
  import ziplib
  import numpy as np
  
  def send_to_db(data, compress=5):
       send( zlib.compress(pkl.dumps(data),compress) )
  </code></pre>
  
  <p>.. but this is extremely slow process.</p>
  
  <p>Even with compress level 0 (without compression), the process is very slow and just because of pickling.</p>
  
  <p>Is there any way to dump numpy array into string without pickle? I know that numpy allows to get buffer <a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.getbuffer.html#numpy.getbuffer" rel="noreferrer">numpy.getbuffer</a>, but it isn't obvious to me, how to use this dumped buffer to obtaine an array back.</p>