title: Optimize Pareto front filtering in Python
body: <p>I'm trying (again: <a href="https://stackoverflow.com/questions/32791911/fast-calculation-of-pareto-front-in-python">Fast calculation of Pareto front in Python</a>) to filter a list of lists to only keep only the non-dominated set.</p>
  
  <p>I put together a script which finally works for me:</p>
  
  <pre><code>import operator
  import copy
  import time
  import random
  
  def select_dominated(a,b):
      ge = all(map(operator.ge, a, b))
      le = all(map(operator.le, a, b))
      # return dominated
      return b if ge else a if le else 'indifferent'
  
  def paretoFront(a):
      b = copy.deepcopy(a)
      if len(a) &gt; 1:
          for i in range(len(a)):
              for j in range(i,len(a)):
                  if i != j:
                      try:
                          b.remove(select_dominated(a[i],a[j]))
                      except:
                          ""
      return b
  
  set = []
  for i in range(1000):
      set.append([random.random(),random.random(),random.random()])
  
  t0 = time.time()
  print len(set),"-&gt;",len(paretoFront(set)),"in",time.time()-t0,"seconds"
  </code></pre>
  
  <p>Expect, for large lists, it's pretty slow (3 sec. to filter 1000 3d points).
  I heard "remove" is pretty slow. How would I go about optimizing this code?</p>