title: python key in dict.keys() performance for large dictionaries
body: <p>I was wondering if you guys might be able to give me some advice in regards to making the performance of my code much better.</p>
  
  <p>I have a set of for loops which look to see if a key is in a dictionary of which its values are a list, if the key exists, it appends to the list and if it doesnt it adds a new list in for that key</p>
  
  <pre><code>dict={}
  for value in value_list:
     if value.key in dict.keys():
        temp_list = dict[value.key]
        temp_list.append(value.val)
        dict[value.key] = temp_list
     else:
        dict[value.key] = [value.val]
  </code></pre>
  
  <p>Now this code works fine, but evenrually as the dictionary starts to fill up the line value.key in dict.keys() becomes more and more cumbersome.</p>
  
  <p>Is there a better way of doing this?</p>
  
  <p>Thanks,</p>
  
  <p>Mike</p>