<div dir="ltr">Sounds like should be an easy patch. Of course, needs to work for ProcessPoolExecutor too.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 1, 2015 at 1:12 AM, Ram Rachum <span dir="ltr"><<a href="mailto:ram@rachum.com" target="_blank">ram@rachum.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>What do you think about adding a method: `Executor.filter`?</div><div><br></div><div>I was using something like this: </div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">my_things = [thing for thing in things if some_condition(thing)]<br></blockquote><br></div><div>But the problem was that `some_condition` took a long time to run waiting on I/O, which is a great candidate for parallelizing with ThreadPoolExecutor. I made it work using `Executor.map` and some improvizing, but it would be nicer if I could do:</div><div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>with concurrent.futures.ThreadPoolExecutor(100) as executor:</div><div>    my_things = executor.filter(some_condition, things)</div><div><br></div></blockquote>And have the condition run in parallel on all the threads.</div><div><br></div><div>What do you think? </div><div><br></div><div><br></div><div>Thanks,</div><div>Ram.</div></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>