mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Merge 313844e6f3 into 7099af8f5e
This commit is contained in:
commit
0c3e515e57
1 changed files with 10 additions and 0 deletions
|
|
@ -2440,6 +2440,16 @@ with the :class:`Pool` class.
|
||||||
the process pool as separate tasks. The (approximate) size of these
|
the process pool as separate tasks. The (approximate) size of these
|
||||||
chunks can be specified by setting *chunksize* to a positive integer.
|
chunks can be specified by setting *chunksize* to a positive integer.
|
||||||
|
|
||||||
|
It is important to distinguish between *maxtasksperchild* in the
|
||||||
|
:class:`Pool` class and *chunksize*. Whereas *maxtasksperchild* denotes
|
||||||
|
how many tasks can be run at once before those resources are freed,
|
||||||
|
*chunksize* defines how many separate chunks in which to split all of the
|
||||||
|
iterations of the function. In order for each iteration of the function to
|
||||||
|
be executed separately, *chunksize* needs to be set to 1.
|
||||||
|
|
||||||
|
Whereas :meth:`imap` defaults to a *chunksize* of 1, :meth:`map` defaults
|
||||||
|
to ``None`` and needs to be declared explicitly.
|
||||||
|
|
||||||
Note that it may cause high memory usage for very long iterables. Consider
|
Note that it may cause high memory usage for very long iterables. Consider
|
||||||
using :meth:`imap` or :meth:`imap_unordered` with explicit *chunksize*
|
using :meth:`imap` or :meth:`imap_unordered` with explicit *chunksize*
|
||||||
option for better efficiency.
|
option for better efficiency.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue