Python Futures And Tuple Unpacking
What is an elagant/idiomatic way to achieve something like tuple unpacking with futures? I have code like a, b, c = f(x) y = g(a, b) z = h(y, c) and I would like to convert it to
Solution 1:
A quick glance at:
https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Future
suggests that you'll have to do something like
afuture = ex.submit(f, x)
a,b,c = afuture.result()
...
submit
returns a Future
object, not the result of running f(x)
.
This SO answer indicates that chaining futures is not trivial:
Post a Comment for "Python Futures And Tuple Unpacking"