title: Python. How to subtract 2 dictionaries
body: <p>I have 2 dictionaries, A and B. A has 700000 key-value pairs and B has 560000 key-values pairs. All key-value pairs from B are present in A, but some keys in A are duplicates with different values and some have duplicated values but unique keys. I would like to subtract B from A, so I can get the remaining 140000 key-value pairs. When I subtract key-value pairs based on key identity, I remove lets say 150000 key-value pairs because of the repeated keys. I want to subtract key-value pairs based on the identity of BOTH key AND value for each key-value pair, so I get 140000. Any suggestion would be welcome.</p>
  
  <p>This is an example:</p>
  
  <pre><code>A = {'10':1, '11':1, '12':1, '10':2, '11':2, '11':3}
  B = {'11':1, '11':2}
  </code></pre>
  
  <p>I DO want to get: 
      A-B = {'10':1, '12':1, '10':2, '11':3}</p>
  
  <p>I DO NOT want to get:</p>
  
  <p>a) When based on keys:</p>
  
  <pre><code>{'10':1, '12':1, '10':2}
  </code></pre>
  
  <p>or</p>
  
  <p>b) When based on values:</p>
  
  <pre><code>{'11':3}
  </code></pre>