3 comments

[ 2.8 ms ] story [ 14.7 ms ] thread
Includes sample code for Python using joblib, in R using the Parallel language, and in Matlab/Octave using the parfor construct!
Parallel looping is one of those things I wish was easier to use. Countless times I've stared at my python code weighing the cost of using the available primitives to optimise the loop. I just wish it was as simple as

  parallel_for x in range(10):
      myFunc(x)
But we can't have everything.
The joblib packages gets you pretty close:

  num_cores = multiprocessing.cpu_count()
  Parallel(n_jobs=num_cores)(
    delayed(myFunc)(x) for x in range(10))