title: Combining Dictionaries Of Lists In Python
body: <p>I have a very large collection of (p, q) tuples that I would like to convert into a dictionary of lists where the first item in each tuple is a key that indexes a list that contains q.</p>
  
  <p>Example:  </p>
  
  <pre><code>Original List: (1, 2), (1, 3), (2, 3)  
  Resultant Dictionary: {1:[2, 3], 2:[3]}  
  </code></pre>
  
  <p>Furthermore, I would like to efficiently combine these dictionaries.</p>
  
  <p>Example:  </p>
  
  <pre><code>Original Dictionaries: {1:[2, 3], 2:[3]}, {1:[4], 3:[1]}  
  Resultant Dictionary: {1:[2, 3, 4], 2:[3], 3:[1]}  
  </code></pre>
  
  <p>These operations reside within an inner loop, so I would prefer that they be as fast as possible.</p>
  
  <p>Thanks in advance</p>