title: Cython Memoryviews -- From Array of Structs?
body: <p>I'd like to quickly fill with as few copies as possible a long array of structs that I'm receiving incrementally from C.</p>
  
  <p>If my struct is only primary data types, like the following:</p>
  
  <pre><code>cdef packed struct oh_hi:
      int lucky
      char unlucky
  </code></pre>
  
  <p>Then the following works fine:</p>
  
  <pre><code>  DEF MAXPOWER = 1000000
    cdef oh_hi * hi2u = &lt;oh_hi *&gt;malloc(sizeof(oh_hi)*MAXPOWER)
    cdef oh_hi [:] hi2me = &lt;oh_hi[:MAXPOWER]&gt; hi2u
  </code></pre>
  
  <p>But once I change my struct to hold a character array: </p>
  
  <pre><code>cdef packed struct oh_hi:
      int lucky
      char unlucky[10]
  </code></pre>
  
  <p>The previous memoryview casting compiles but when run gives a:</p>
  
  <pre><code>  ValueError: Expected 1 dimension(s), got 1
  </code></pre>
  
  <p>Is there an easy way to do this in Cython? I'm aware that I could create a structured array, but afaik, that wouldn't let me assign the C structs straight into it.</p>