title: python multiprocessing, cpu-s and cpu cores
body: <p>I was trying out <code>python3</code> <code>multiprocessing</code> on a machine that has 8 cpu-s and each cpu has four cores (information is from <code>/proc/cpuinfo</code>). I wrote a little script with a useless function and I use <code>time</code> to see how long it takes for it to finish.</p>
  
  <pre><code>from multiprocessing import Pool,cpu_count
  def f(x):
      for i in range(100000000):
          x*x
      return x*x
  with Pool(8) as p:
      a = p.map(f,[x for x in range(8)])
  #~ f(5)
  </code></pre>
  
  <p>Calling <code>f()</code> without multiprocessing takes about 7s (<code>time</code>'s "real" output). Calling <code>f()</code> 8 times with a pool of 8 as seen above, takes around 7s again. If I call it 8 times with a pool of 4 I get around 13.5s, so there's some overhead in starting the script, but it runs twice as long. So far so good. Now here comes the part that I do not understand. If there are 8 cpu-s each with 4 cores, if I call it 32 times with a pool of 32, as far as I see it should run for around 7s again, but it takes 32s which is actually slightly longer than running <code>f()</code> 32 times on a pool of 8.</p>
  
  <p>So my question is <code>multiprocessing</code> not able to make use of cores or I don't understand something about cores or is it something else?</p>