title: Cython malloc struct to python
body: <p>How can I go about converting this line into python from cython. I want to try to avoid using any cython if possible.</p>
  <pre><code>cdef qnode *q = &lt;qnode *&gt; malloc((4 * height * width + 1) * sizeof(qnode))
  </code></pre>
  <p>Here are the struct details and I am getting  a subscriptable error. The top is the original cython and the bottom is my new class.</p>
  <pre><code>#ctypedef struct qnode:
  #    int row
  #    int col
  #    int layer
  #    int orig_row
  #    int orig_col
  
  class qnode:
      def __init__(self):
          self.row = 0
          self.col = 0
          self.layer = 0
          self.orig_row = 0
          self.orig_col = 0
  
  q = qnode()
  
  </code></pre>
  <p>This line is the main issue and I need to be able to keep this stack like operation.</p>
  <pre><code>q[-1].row = x
  </code></pre>
  <p>Following that how can how also go about converting the free(q) command as well.</p>