title: python data structure suggestion
body: <p>I have some input coming from various sources. Input is in key value pair form. Keys are of type 'a.b.c' form. Keys coming in from different sources can be same and in that case i have to do a set of all values. </p>
  
  <p>Things I need to do with the data structure:</p>
  
  <ul>
  <li>I should be able to retrieve all the keys and values for a specific source id</li>
  <li>Given a key, I should be able to find out all the values associated with it, irrespective of the source id.</li>
  </ul>
  
  <p>I want one or more space efficient data structures I can use to achieve this. I was originally thinking of keeping 2 maps: one for source id vs keys, and other for key vs values. But here I am losing the source id to value mapping.</p>
  
  <p>Speed/Space requirements:
  The speed to get a list of values per key is important; so is the memory required to maintain these data structures. Time taken to build this data structure and source id to key/value retrieval speed isn't vital.</p>
  
  <p>Any suggestions?</p>