New submission from Josh Rosenberg:

As currently implemented, Executor.map is not particularly lazy. Specifically, 
if given huge argument iterables, it will not begin yielding results until all 
tasks have been submitted; if given an infinite input iterable, it will run out 
of memory before yielding a single result.

This makes it unusable as a drop in replacement for plain map, which, being 
lazy, handles infinite iterables just fine, and produces results promptly.

Proposed change makes Executor.map begin yielding results for large iterables 
without submitting every task up front. As a reasonable default, I have it 
submit a number of tasks equal to twice the number of workers, submitting a new 
task immediately after getting results for the next future in line, before 
yielding the result (to ensure the number of outstanding futures stays 
constant). A new keyword-only argument, prefetch, is provided to explicitly 
specify how many tasks should be queued above and beyond the number of workers.

Working on submitting pull request now.

----------
components: Library (Lib)
messages: 289789
nosy: josh.r
priority: normal
severity: normal
status: open
title: Executor.map should not submit all futures prior to yielding any results
versions: Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29842>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to