title: Evaluating the performance gain from multi-threading in python
body: <p>I tried to compare the performance gain from parallel computing using multithreading module and the normal sequence computing but couldn't find any real difference. Here's what I did:</p>
  
  <pre><code>import time, threading, Queue
  q=Queue.Queue()
  
  def calc(_range):
      exponent=(x**5 for x in _range)
      q.put([x**0.5 for x in exponent])
  
  def calc1(_range):
      exponent=(x**5 for x in _range)
      return [x**0.5 for x in exponent]
  
  def multithreds(threadlist):
      d=[]
      for x in threadlist:
          t=threading.Thread(target=calc, args=([x]))
          t.start()
          t.join()
          s=q.get()
          d.append(s)
      return d
  
  
  threads=[range(100000), range(200000)]
  
  start=time.time()
  #out=multithreads(threads)
  out1=[calc1(x)for x in threads]
  end=time.time()
  print end-start
  </code></pre>
  
  <p>Timing using threading:<code>0.9390001297</code>
  Timing running in sequence:<code>0.911999940872</code></p>
  
  <p>The timing running in sequence was constantly lower than using multithreading.
  I have a feeling there's something wrong with my multithreading code.</p>
  
  <p>Can someone point me in the right direction please.
  Thanks.</p>