title: How to get bytes from interleave of numpy arrays with different dtype?
body: <p>Say I have two numpy arrays of different type</p>
  <pre><code>a = np.array([1, 3], dtype=np.int32)
  b = np.array([[1.1, 4.4, 1.7],
                [1.1, 7.5, 8.2]], dtype=np.float32)
  </code></pre>
  <p>using <code>a.tobytes()</code> and <code>b.tobytes()</code> gives me the expected outputs:</p>
  <pre><code># a.tobytes() is
  b'\x01\x00\x00\x00\x03\x00\x00\x00'
  # b.tobytes() is
  b'\xcd\xcc\x8c?\xcd\xcc\x8c@\x9a\x99\xd9?\xcd\xcc\x8c?\x00\x00\xf0@33\x03A'
  </code></pre>
  <p>I would like to interleave the two like arrays to obtain bytes like this:</p>
  <pre><code># The order I want is a[0] b[0] a[1] b[1].
  b'\x01\x00\x00\x00\xcd\xcc\x8c?\xcd\xcc\x8c@\x9a\x99\xd9?\x03\x00\x00\x00\xcd\xcc\x8c?\x00\x00\xf0@33\x03A'
  </code></pre>
  <p>I tried using numpy because the code is not verbose and executes faster than my (successful but slow) for loop implementation.</p>
  <pre><code>ab = np.empty((2, 4), dtype=object)
  ab[:, 0] = a
  ab[:, 1:] = b
  
  # ab will then be
  array([[1, 1.100000023841858, 4.400000095367432, 1.7000000476837158],
         [3, 1.100000023841858, 7.5, 8.199999809265137]], dtype=object)
  </code></pre>
  <p>However I can't use <code>ab.tobytes()</code> anymore because the type <code>object</code> isn't even 32 bit anymore. The output is:</p>
  <pre><code>b&quot;0'b\xfb\xfb\x7f\x00\x00p.\xaf`\x87\x01\x00\x00\xf0-\xaf`\x87\x01\x00\x00\x10&amp;\xaf`\x87\x01\x00\x00p'b\xfb\xfb\x7f\x00\x00P,\xaf`\x87\x01\x00\x00P%\xaf`\x87\x01\x00\x00P)\xaf`\x87\x01\x00\x00&quot;
  </code></pre>
  <p>Ultimately I want to write the bytes to a file.</p>