title: Fastest way of deleting certain keys from dict in Python
body: <p>I'm looking for most fastest/effective way of deleting certain keys in a python dict</p>
  
  <p>Here are some options</p>
  
  <pre><code>for k in somedict.keys(): 
      if k.startswith("someprefix"): 
          del somedict[k]
  </code></pre>
  
  <p>or</p>
  
  <pre><code>dict((k, v) for (k, v) in somedict.iteritems() if not k.startswith('someprefix'))
  </code></pre>
  
  <p>Logically first snippet should be faster on smaller dicts, it doesn't create a copy of a dict but creates a list of all keys, however double lookups and dict rebuilding is time consuming. While the second is faster on bigger dicts, but requires 2x more memory.
  I've checked my assumption in some small benchmark.</p>
  
  <p>Anything faster? </p>