title: How to remove duplicate dictionaries based on 2 keys?
body: <p>I want to remove duplicate dictionaries based on 2 keys. Is there a faster way to do this?</p>
  
  <p>What I've tried so far.</p>
  
  <pre><code>def remove_duplicates(documents):
      unique_documents = [documents[0]]  # Initialize first dict
      for document in documents:
          for index, unique_document in enumerate(unique_documents):
              if unique_document['user'] == document['user']:
                  if unique_document['text'] == document['text']:
                      # If the user and text are found, then it's a duplicate.
                      # Go to next document.
                      break
                  if index == len(unique_documents)-1:
                      # If it reaches the last dict of the unique_documents,
                      # append to list because the dict is unique
                      unique_documents.append(document)
  
      return unique_documents
  </code></pre>
  
  <p>There are 7 keys per dict in the list of dicts and using the code above with a test data of <strong>99942</strong> <strong>documents</strong> took <strong>1457.94099998s</strong> or <strong>24mins</strong> to process. Is there a more efficient way to do this?</p>