<div dir="auto">I had forgotten about Daisy! It's an interesting project too. The behavior of 'autodask()' is closer to what I'd want in new syntax than is plain dask.delayed(). I'm not sure of all the corners. But is definitely love to have it for expressions generally, not only pure functions.</div><div class="gmail_extra"><br><div class="gmail_quote">On Feb 17, 2017 12:03 AM, "Joseph Jevnik" <<a href="mailto:joejev@gmail.com">joejev@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">You can let dask "see" into the function by entering it and wrapping all of the operations in `delayed`; this is how daisy[0] builds up large compute graphs. In this case, you could "inline" the identity function and the delayed object would flow through the function and the call to identity never makes it into the task graph.<br><br>[0] <a href="http://daisy-python.readthedocs.io/en/latest/appendix.html#daisy.autodask" target="_blank">http://daisy-python.<wbr>readthedocs.io/en/latest/<wbr>appendix.html#daisy.autodask</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 17, 2017 at 2:26 AM, David Mertz <span dir="ltr"><<a href="mailto:mertz@gnosis.cx" target="_blank">mertz@gnosis.cx</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"><div class="gmail_extra"><div class="gmail_quote"><span>On Thu, Feb 16, 2017 at 11:15 PM, David Mertz <span dir="ltr"><<a href="mailto:mertz@gnosis.cx" target="_blank">mertz@gnosis.cx</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><span style="font-size:11.2px"><font face="arial, helvetica, sans-serif">This also means that a 'delayed' object needs to be idempotent.  So</font></span></div><div><span style="font-size:11.2px"><font face="arial, helvetica, sans-serif"><br></font></span></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-size:11.2px"><font face="monospace, monospace">x = delayed 2+2</font></span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-size:11.2px"><font face="monospace, monospace">y = delayed x</font></span></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><span style="font-size:11.2px"><font face="monospace, monospace">z = delayed delayed delayed y</font></span></div></blockquote><font face="arial, helvetica, sans-serif"><span style="font-size:11.2px"><br></span></font><div><font face="arial, helvetica, sans-serif"><span style="font-size:11.2px">Wrapping more delays around an existing delayed object should probably just keep the same object rather than "doubly delaying" it.  If there is some reason to create separate delayed objects that isn't occurring to me, evaluating 'z' would still go through the multiple evaluation levels until it got to a non-delayed value.</span></font></div></div></blockquote><div><br></div></span><div>This is sort of like how iterators "return self" and 'it = iter(it)'.</div><div><br></div><div>In the case of Dask, wrapping more delayed objects creates layers of these lazy objects.  But I think it has to because it's not part of the syntax.  Actually, I guess Dask could do graph reduction without actual computation if it wanted to.  But this is the current behavior:</div><div><br></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">>>> def unchanged(x):</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">...     return x</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">>>> a = delayed(unchanged)(42)</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="font-family:monospace,monospace">>>> a</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">Delayed('unchanged-1780fed6-f8<wbr>35-4c31-a86d-50015ae1449a')</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="font-family:monospace,monospace">>>> b = delayed(unchanged)(a)</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="font-family:monospace,monospace">>>> c = delayed(unchanged)(b)</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="font-family:monospace,monospace">>>> c</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">Delayed('unchanged-adc5e307-6e<wbr>33-45bf-ad73-150b906e921d')</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="font-family:monospace,monospace">>>> c.dask</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="font-family:monospace,monospace">{'unchanged-1780fed6-f835-4c31<wbr>-a86d-50015ae1449a': (<function __main__.unchanged>,</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">  42),</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> 'unchanged-adc5e307-6e33-45bf<wbr>-ad73-150b906e921d': (<function __main__.unchanged>,</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">  'unchanged-c3282bc4-bdaa-4148-<wbr>8509-9155cac83ef0'),</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"> 'unchanged-c3282bc4-bdaa-4148<wbr>-8509-9155cac83ef0': (<function __main__.unchanged>,</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">  'unchanged-1780fed6-f835-4c31-<wbr>a86d-50015ae1449a')}</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace"><br></font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><span style="font-family:monospace,monospace">>>> c.compute()</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">42 </font></div></div></div></blockquote><div class="gmail_extra"><br></div><div class="gmail_extra">Actually Dask <b>cannot</b> know that "unchanged()" is the function that makes no transformation on its one parameter.  From what it can see, it's just a function that does <b>something</b>.  And I guess similarly in the proposed syntax, anything other than a plain name after the 'delayed' would still need to create a new delayed object.  So it's all an edge case that doesn't make much difference.<span><br clear="all"><div><br></div>-- <br><div class="m_2442990671274612690m_5167032093325660184gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</span></div></div>
</blockquote></div><br></div>
</blockquote></div></div>