title: Assign bytes to Cython memory view
body: <p>I have a memory view of a 2-dimensional Cython array defined as</p>
  <pre><code>cdef unsigned char[:,:] store = view.array(
      shape=(n, 141),
      itemsize=sizeof(unsigned char),
      format=&quot;B&quot;,
  )
  </code></pre>
  <p>, where <code>n</code> is the number of &quot;rows&quot; I have. For the sake of the example, lets assume <code>n=2</code>. Each row is a Python bytes object of size 141, which I have in a list of <code>bytes</code>:</p>
  <pre><code>rows = [
      b&quot;4612edc38e7acc81520860b210c4ae7a14ace72bbb710514bd5ef71bb96e7af55b307580b015efac3cb84339fa9ff99401ed6fe211bb75b937fa575fc3928500c511aee084e5c&quot;,
      b&quot;beb71c68b420fcb093d7c5894d726239bb0620229e46f91c11d3c2cd688e37c0c279ec844152cf87ea6c3f6915ac90aeb83ade44dfe22b1ae9c6fdd87e813eed98e5faca4d250&quot;,
  ]
  </code></pre>
  <p>I now want to move the data inside these rows into the memory view. At the moment, I'm doing this in a rather stupid way:</p>
  <pre><code>for i, row in enumerate(rows):
      for j, byte_ in enumerate(row):
          store[i, j] = byte_
  </code></pre>
  <p>While this works, I assume it is inefficient (unless <code>cythonize</code> does some magic to get rid of the loops), and it just looks messy and overly complicated. I want to be able to simply do something like:</p>
  <pre><code>store[:,:] = rows
  </code></pre>
  <p>or, at least:</p>
  <pre><code>for i, row in enumerate(rows):
      store[i, :] = row # fails with TypeError: an integer is required
  </code></pre>
  <hr />
  <p>Sadly, none of that works. I also tried the following:</p>
  <pre><code># fails because the resulting number is a bigint (?)
  store[i, :] = int.from_bytes(bytearray, sys.byteorder)
  # fails with TypeError: an integer is required
  store[i, :] = np.array(list(row))
  </code></pre>
  <hr />
  <p>There must be a better way. What am I missing?</p>