On 24.05.20 19:38, David Mertz wrote:
As syntax, I presume this would be something like:
output = [] for x in data: a = delayed inc(x) b = delayed double(x) c = delayed add(a, b) output.append(c)
total = sum(outputs) # concrete answer here.
Obviously the simple example of adding scalars isn't worth the delay thing. But if those were expensive operations that built up a call graph, it could be useful laziness.
Do you have an example which can't be solved by using generator expressions and itertools? As far as I understand the Dask docs the purpose of this is to execute in parallel which wouldn't be the case for pure Python I suppose? The above example can be written as: a = (inc(x) for x in data) b = (double(x) for x in data) c = (add(x, y) for x, y in zip(a, b)) total = sum(c)