Created
April 12, 2021 21:14
-
-
Save pgalilea/d507336ed69f0d5a9dfd77ac1d3ee7ab to your computer and use it in GitHub Desktop.
Embarrassingly parallel for loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
import multiprocessing | |
from joblib import Parallel, delayed | |
nj= max( 2, multiprocessing.cpu_count() ) | |
Parallel(n_jobs=nj)( delayed(sqrt)(i ** 2) for i in range(10) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment