title: Access list of items with list of indices
body: <p>Consider a large list of named items (first line) returned from a large csv file (80 MB) with possible interrupted spacing</p>
  
  <pre><code>name_line =  ['a',,'b',,'c' .... ,,'cb','cc']
  </code></pre>
  
  <p>I am reading the remainder of the data in line by line and I only need to process data with a corresponding name. Data might look like</p>
  
  <pre><code>data_line =  ['10',,'.5',,'10289' .... ,,'16.7','0']
  </code></pre>
  
  <p>I tried it two ways. One is popping the empty columns from each line of the read</p>
  
  <pre><code>blnk_cols = [1,3, ... ,97]
  while data:
      ...
      for index in blnk_cols: data_line.pop(index)
  </code></pre>
  
  <p>the other is compiling the items associated with a name from L1</p>
  
  <pre><code>good_cols = [0,2,4, ... ,98,99]   
  while data:
      ...
      data_line = [data_line[index] for index in good_cols]
  </code></pre>
  
  <p>in the data I am using there will definitely be more good lines then bad lines although it might be as high as half and half.</p>
  
  <p>I used the cProfile and pstats package to determine my weakest links in speed which suggested the pop was the current slowest item. I switched to the list comp and the time almost doubled. </p>
  
  <p>I imagine one fast way would be to slice the array retrieving only good data, but this would be complicated for files with alternating blank and good data. </p>
  
  <p>what I really need is to be able to do </p>
  
  <pre><code>data_line = data_line[good_cols]
  </code></pre>
  
  <p>effectively passing a list of indices into a list to get back those items. 
  Right now my program is running in about 2.3 seconds for a 10 MB file and the pop accounts for about .3 seconds. </p>
  
  <p>Is there a faster way to access certain locations in a list. In C it would just be de-referencing an array of pointers to the correct indices in the array.</p>
  
  <p>Additions:
  name_line in file before read</p>
  
  <pre><code>a,b,c,d,e,f,g,,,,,h,i,j,k,,,,l,m,n,
  </code></pre>
  
  <p>name_line after read and split(",")</p>
  
  <pre><code>['a','b','c','d','e','f','g','','','','','h','i','j','k','','','','l','m','n','\n']
  </code></pre>