title: Multithreading through items in a list (Python)
body: <p>currently I'm scripting a heuristic problem in Python and I'm trying to make the script as fast as possible. The script is working and now it's the challenge to optimize it. I want to use multithreading (or multiprocessing) to do a small piece of my whole code, here's the piece of code I'm talking about:</p>
  
  <pre><code>valid_children = set()
  for focus_genome in a_list_of_genomes: # a list of objects
      [valid_children.update(set([child])) for child in \ 
      focus_genome.children() if not child in all_genomes]
  </code></pre>
  
  <p>which is basically the same as, more readable:</p>
  
  <pre><code>valid_children = set()
  for focus_genome in a_list_of_genomes: # a list of objects
      children = focus_genome.children()
      for child in children: # a list of objects (again)
          if child in all_genomes:
              valid_children.update(set([child]))
  </code></pre>
  
  <p>all_genomes is a list with all found genomes yet.</p>
  
  <p>I tried the following but it doesn't update the set:</p>
  
  <pre><code>def threaded_function(focus_genome):
      # same as above
      [valid_children.update(set([child])) for child in focus_genome.children() \
      if not child in all_genomes]
  
  def main_function():
      ...
      do things
      ...
      thread = Thread(target = threaded_function, args = (focus_genome,) )
      thread.start()
      thread.join()
  </code></pre>
  
  <p>Who can help me get back on the road ? Thanks in advance!</p>