title: Comparing list of unique objects with custom function
body: <p>I need to <strong>compare hundreds of objects</strong> stored in a unique list to find duplicates:</p>
  
  <pre><code>object_list = {Object_01, Object_02, Object_03, Object_04, Object_05, ...}
  </code></pre>
  
  <p>I've written a custom function, which returns <code>True</code>, if the objects are equal and <code>False</code> if not:</p>
  
  <pre><code>object_01.compare(object_02)
  &gt;&gt;&gt; True
  </code></pre>
  
  <p>Compare method works well, but takes a lot of time per execution. I'm currently using <code>itertools.combinations(x, 2)</code> to <strong>iterate through all combinations</strong>. I've thought it's a good idea to use a dict for storing already compared objects and create new sets dynamically like:</p>
  
  <pre><code>dct = {'Compared': {}}
  dct['Compared'] = set()
  
  import itertools
  for a, b in itertools.combinations(x, 2):
  
      if b.name not in dct['Compared']:
  
          if compare(a,b) == True:
  
              #print (a,b)
              key = a.name
              value = b.name
  
              if key not in dct:
                  dct[key] = set()
                  dct[key].add(value)
              else:
                  dct[key].add(value)
  
              dct[key].add(key)
  
      dct['Compared'].add(b)
  </code></pre>
  
  <p><strong>Current Output:</strong></p>
  
  <pre><code>Compared: {'Object_02', 'Object_01', 'Object_03', 'Object_04', 'Object_05'}
  Object_01: {'Object_02', 'Object_03', 'Object_01'}
  Object_04: {'Object_05', 'Object_04'}
  Object_05: {'Object_04'}
  ...
  </code></pre>
  
  <p>I would like to know: <strong>Is there a faster way to iterate through all combinations</strong> and how to <em>break/prevent</em> the iteration of an object, which is already assigned to a list of duplicates?</p>
  
  <p><strong>Desired Output:</strong></p>
  
  <pre><code>Compared: {'Object_02', 'Object_01', 'Object_03', 'Object_04', 'Object_05'}
  Object_01: {'Object_02', 'Object_03', 'Object_01'}
  Object_04: {'Object_05', 'Object_04'}
  ...
  </code></pre>
  
  <p><strong>Note:</strong> Compare method is a c-wrapper. Requirement is to find an algorithm around it.</p>