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)

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4556SWPB4UNBZBXD4LM57UCA7ESVENVM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to