Commit b8f62c17 authored by Radek Hušek's avatar Radek Hušek Committed by Radek Hušek
Browse files

parmap: Add option to not preserve order of items

parent 9e5925c9
......@@ -33,7 +33,8 @@ def worker_fun(f, q_in, q_out):
break
q_out.put((i, [ f(x) for x in chunk ]))
def parmap(f, X, nprocs = None, chunksize = 1, chunks_in_flight = None):
def parmap(f, X, nprocs = None, chunksize = 1, chunks_in_flight = None,
inOrder = True):
if nprocs is None:
nprocs = multiprocessing.cpu_count()
......@@ -70,6 +71,12 @@ def parmap(f, X, nprocs = None, chunksize = 1, chunks_in_flight = None):
jobs = val
continue
if not inOrder:
chunk_index += 1
cont.release()
yield val
continue
ret[i] = val
while chunk_index in ret:
val = ret[chunk_index]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment