title: Removing duplicate interaction pairs in python sets
body: <p>suppose you have a list of tuples in a python set:</p>
  
  <pre><code>&gt;&gt;&gt; pairs = set( [(0,1),(0,1),(1,0)] )
  &gt;&gt;&gt; print pairs
  set([(0, 1), (1, 0)])
  </code></pre>
  
  <p>Obviously, the first two elements are duplicates and according
  to the definition of a set, "pairs" only holds unique elements.</p>
  
  <p>However, in my particular case the tuple (i,j) defines an interaction pair. Thus,
  (i,j) and (j,i) are the same. I need an effective way to reduce all duplicate 
  elements. Computation time is crucial for me since the total set could easily contain a number of element as large as 10**6. I expect the following result:</p>
  
  <pre><code>&gt;&gt;&gt; pairs = set( [(0,1),(0,1),(1,0)] )
  &gt;&gt;&gt; pairs = remove_duplicate_interactions(pairs)
  &gt;&gt;&gt; print pairs
  set([0,1]) or set([1,0])
  </code></pre>
  
  <p>I am thankful for any hint.</p>
  
  <p>Edit:</p>
  
  <p>Someone asked about the context. This is supposed to be used for particle simulations.
  Due to symmetry conditions, the force of particle i acting on j is the same as the force of j acting on i. The reduction of computation time is thus 50 %.</p>