Does joblib.Parallel keep the original order of data passed?
TL;DR - it preserves order for both backends.
Extending @Chris Farr's answer, I implemented a simple test. I make a function wait for some random amount of time (you can check these wait times are not identical). I get that the order is preserved every time, with both backends.
from joblib import Parallel, delayed
import numpy as np
import time
def f(wait):
time.sleep(wait)
return wait
n = 50
waits = np.random.uniform(low=0, high=1, size=n)
res = Parallel(n_jobs=8, backend='multiprocessing')(delayed(f)(wait) for wait in waits)
np.all(res == waits)
Per the joblib documentation you can specify the backend
asmultiprocessing
which is based on multiprocessing.Pool
. Then the other answer would apply that the results are in fact ordered.
Parallel(n_jobs=2, backend="multiprocessing")(delayed(sqrt)(i ** 2) for i in x)
By default, however, they use loky and it isn't immediately clear but it could be detected by implementing tests.