title: How to iterate an array in Python pointer-likely and efficiently?
body: <p>I am quite new in Python, I would like to iterate an array to calculate the next element based on the previous elements. I can just think of this in C++ manner but how to achieve this in Python using Numpy or Pandas? I know that the similar method is using shifting but that way seems not really efficient.</p>
  
  <p>The following is a simple Fibonacci example:</p>
  
  <pre><code>int arr[10];
  arr[0] = 1;
  arr[1] = 1;
  
  int* pt = &amp;arr[2];         &lt;--get a iterator like a moving pointer
  int count = 8;
  while (count &gt; 0)
  {
      *pt = pt[-1] + pt[-2]; &lt;--access previous k element based on current index
      count--;
      pt++;                  &lt;--point to next element
  }
  for (int i = 0; i &lt; 10; i++)
      cout &lt;&lt; arr[i] &lt;&lt; endl;
  </code></pre>
  
  <p>List:</p>
  
  <pre><code>L = [1, 1]
  while len(L) != 10:
      L.append(L[-1] + L[-2]) &lt;--But I have to append element every time
  print L
  </code></pre>