Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Radek Hušek
group-connectivity-pub
Commits
b8f62c17
Commit
b8f62c17
authored
Dec 11, 2015
by
Radek Hušek
Committed by
Radek Hušek
Nov 09, 2017
Browse files
parmap: Add option to not preserve order of items
parent
9e5925c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
parmap.py
View file @
b8f62c17
...
...
@@ -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
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment