title: Joblib Parallel multiple cpu's slower than single
body: <p>I've just started using the Joblib module and I'm trying to understand how the Parallel function works. Below is an example of where parallelizing leads to longer runtimes but I don't understand why. My runtime on 1 cpu was 51 sec vs. 217 secs on 2 cpu.</p>
  
  <p>My assumption was that running the loop in parallel would copy lists a and b to each processor. Then dispatch item_n to one cpu and item_n+1 to the other cpu, execute the function and then write the results back to a list (in order). Then grab the next 2 items and so on. I'm obviously missing something. </p>
  
  <p>Is this a poor example or use of joblib?  Did I simply structure the code wrong? </p>
  
  <p>Here is the example:</p>
  
  <pre><code>import numpy as np
  from matplotlib.path import Path
  from joblib import Parallel, delayed
  
  ## Create pairs of points for line segments
  a = zip(np.random.rand(5000,2),np.random.rand(5000,2))
  
  b = zip(np.random.rand(300,2),np.random.rand(300,2))
  
  ## Check if one line segment contains another. 
  def check_paths(path, paths):
      for other_path in paths:
          res='no cross'
          chck = Path(other_path)
          if chck.contains_path(path)==1:
              res= 'cross'
              break
      return res
  
  res = Parallel(n_jobs=2) (delayed(check_paths) (Path(points), a) for points in b)
  </code></pre>