https://github.com/python/cpython/commit/547c135d70760f974ed0476a32a6809e708bfe4d
commit: 547c135d70760f974ed0476a32a6809e708bfe4d
branch: main
author: NewUserHa <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-01-27T10:29:38+02:00
summary:

Simplify concurrent.futures.process code by using itertools.batched() 
(GH-114221)

files:
M Lib/concurrent/futures/process.py

diff --git a/Lib/concurrent/futures/process.py 
b/Lib/concurrent/futures/process.py
index ffaffdb8b3d0aa..ca843e11eeb83d 100644
--- a/Lib/concurrent/futures/process.py
+++ b/Lib/concurrent/futures/process.py
@@ -190,16 +190,6 @@ def _on_queue_feeder_error(self, e, obj):
             super()._on_queue_feeder_error(e, obj)
 
 
-def _get_chunks(*iterables, chunksize):
-    """ Iterates over zip()ed iterables in chunks. """
-    it = zip(*iterables)
-    while True:
-        chunk = tuple(itertools.islice(it, chunksize))
-        if not chunk:
-            return
-        yield chunk
-
-
 def _process_chunk(fn, chunk):
     """ Processes a chunk of an iterable passed to map.
 
@@ -847,7 +837,7 @@ def map(self, fn, *iterables, timeout=None, chunksize=1):
             raise ValueError("chunksize must be >= 1.")
 
         results = super().map(partial(_process_chunk, fn),
-                              _get_chunks(*iterables, chunksize=chunksize),
+                              itertools.batched(zip(*iterables), chunksize),
                               timeout=timeout)
         return _chain_from_iterable_of_lists(results)
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to