title: Improve Runtime to reduce list 1 to only contain entries that match to list 2 in python
body: <p>I am working with sequencing data and need to count the number of reads that match to a grna library in python. Simplified my data looks like this:</p>
  <pre><code>reads = ['abc', 'abc','def', 'ghi']
  grnas = ['abc', 'ghi']
  </code></pre>
  <p>The grnas list is unique, while the reads list can contain entries that are not of interest and don't match to the grnas or are repeat entries. What I want to do is to reduce the list of reads to only contain those entries which match to one entry in grnas.</p>
  <p>I am currently doing this with a list comprehension like this:</p>
  <pre><code>reads_matched = [read for read in reads if (read in grnas)]
  </code></pre>
  <p>in my example for reads_matched this would return :</p>
  <pre><code>['abc', 'abc', 'ghi']
  </code></pre>
  <p>Since both of my lists are very large (6 million entries in reads and 80k entries in grnas) this of course takes some time to compute. Is there any way for me to speed this up further?</p>
  <p>I have tried writing it as a for loop or while loop in many different variations but this is much slower than the method I listed above. In general I am very inexperienced with runtime improvements and have come to this solution through trial and error so any tips to further improve would be appreciated!</p>