Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9290503

Browse files
committed
#4206: fix 2.xisms in multiprocessing docs and docstrings.
1 parent 59d64f7 commit 9290503

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

Doc/library/multiprocessing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,8 @@ with the :class:`Pool` class.
14471447

14481448
.. method:: map(func, iterable[, chunksize])
14491449

1450-
A parallel equivalent of the :func:`map` builtin function. It blocks till
1451-
the result is ready.
1450+
A parallel equivalent of the :func:`map` builtin function, collecting the
1451+
result in a list. It blocks till the whole result is ready.
14521452

14531453
This method chops the iterable into a number of chunks which it submits to
14541454
the process pool as separate tasks. The (approximate) size of these
@@ -1465,7 +1465,7 @@ with the :class:`Pool` class.
14651465

14661466
.. method:: imap(func, iterable[, chunksize])
14671467

1468-
An lazier version of :meth:`map`.
1468+
A lazier version of :meth:`map`.
14691469

14701470
The *chunksize* argument is the same as the one used by the :meth:`.map`
14711471
method. For very long iterables using a large value for *chunksize* can

Lib/multiprocessing/pool.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def worker(inqueue, outqueue, initializer=None, initargs=()):
7676

7777
class Pool(object):
7878
'''
79-
Class which supports an async version of the `apply()` builtin
79+
Class which supports an async version of applying functions to arguments.
8080
'''
8181
Process = Process
8282

@@ -135,21 +135,22 @@ def _setup_queues(self):
135135

136136
def apply(self, func, args=(), kwds={}):
137137
'''
138-
Equivalent of `apply()` builtin
138+
Equivalent of `func(*args, **kwds)`.
139139
'''
140140
assert self._state == RUN
141141
return self.apply_async(func, args, kwds).get()
142142

143143
def map(self, func, iterable, chunksize=None):
144144
'''
145-
Equivalent of `map()` builtin
145+
Apply `func` to each element in `iterable`, collecting the results
146+
in a list that is returned.
146147
'''
147148
assert self._state == RUN
148149
return self.map_async(func, iterable, chunksize).get()
149150

150151
def imap(self, func, iterable, chunksize=1):
151152
'''
152-
Equivalent of `itertool.imap()` -- can be MUCH slower than `Pool.map()`
153+
Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.
153154
'''
154155
assert self._state == RUN
155156
if chunksize == 1:
@@ -167,7 +168,7 @@ def imap(self, func, iterable, chunksize=1):
167168

168169
def imap_unordered(self, func, iterable, chunksize=1):
169170
'''
170-
Like `imap()` method but ordering of results is arbitrary
171+
Like `imap()` method but ordering of results is arbitrary.
171172
'''
172173
assert self._state == RUN
173174
if chunksize == 1:
@@ -185,7 +186,7 @@ def imap_unordered(self, func, iterable, chunksize=1):
185186

186187
def apply_async(self, func, args=(), kwds={}, callback=None):
187188
'''
188-
Asynchronous equivalent of `apply()` builtin
189+
Asynchronous version of `apply()` method.
189190
'''
190191
assert self._state == RUN
191192
result = ApplyResult(self._cache, callback)
@@ -194,7 +195,7 @@ def apply_async(self, func, args=(), kwds={}, callback=None):
194195

195196
def map_async(self, func, iterable, chunksize=None, callback=None):
196197
'''
197-
Asynchronous equivalent of `map()` builtin
198+
Asynchronous version of `map()` method.
198199
'''
199200
assert self._state == RUN
200201
if not hasattr(iterable, '__len__'):

0 commit comments

Comments
 (0)