title: Most efficient way to compare two dictionaries in python
body: <pre><code>dic1 = {'memory':'4','cpu':'2','disk':{'total':'160','swap':'4','/':'26','/var':'7','/tmp':'2'}}
  
  dic2 = {'memory':8','cpu':'2','disk':{'total':'120,'swap':'4','/':'26','/var':'7','/tmp':'2'}}
  </code></pre>
  
  <p>Please note that both dictionaries itself contains another dictionary.
  What is the most efficient way to compare each items without doing dict1==dict2 ?</p>
  
  <p>Since i have to see some % change in values. So the only option left is iterating thru each dictionary items. something like:</p>
  
  <pre><code>for key1 in dic1:
     for key2 in dic2:
        if not isinstance(dic1[key1],dict):
           #compare cpu &amp; memory here
           if int(dic1[key1]) &gt; int(dict2[key2])
        else:
            #compare disk(internal dictionary here)
  </code></pre>