title: Loop through keys if value is greater than 2
body: <p>I have a Python dictionary which has a large (~1.5 million) number of keys. The value associated with each key is a number and I only want to report on values that have values greater than two.</p>
  
  <p>My current code looks something like:</p>
  
  <pre><code>ks_ignored = 0
  for k in d.keys():
      if( d[k] &gt; 2 ):
          print "Key(%s) has value %s"%( k, d[k] )
      else: 
          ks_ignored += 1
  </code></pre>
  
  <p>My final report shows that about 1.4 million keys were ignored and this takes a very long time to run (about 6 hours). Is there a simple way to loop through all keys which have a value greater than 2 without having to perform the check inside of the loop that will substantially speed this up?</p>