Python: remove lots of items from a list
<p>I am in the final stretch of a project I have been working on.  Everything is running smoothly but I have a bottleneck that I am having trouble working around.</p>

<p>I have a list of tuples.  The list ranges in length from say 40,000 - 1,000,000 records.  Now I have a dictionary where each and every (value, key) is a tuple in the list.</p>

<p>So, I might have</p>

<pre><code>myList = [(20000, 11), (16000, 4), (14000, 9)...]
myDict = {11:20000, 9:14000, ...}
</code></pre>

<p>I want to remove each (v, k) tuple from the list.</p>

<p>Currently I am doing:</p>

<pre><code>for k, v in myDict.iteritems():
    myList.remove((v, k))
</code></pre>

<p>Removing 838 tuples from the list containing 20,000 tuples takes anywhere from 3 - 4 seconds.  I will most likely be removing more like 10,000 tuples from a list of 1,000,000 so I need this to be faster.</p>

<p>Is there a better way to do this?</p>

<p>I can provide code used to test, plus pickled data from the actual application if needed.</p>
