<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 17, 2017 at 6:20 PM, Nathaniel Smith <span dir="ltr"><<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</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">
value = delayed: some_dict.get("whatever")<br>
if value is None:<br>
...<br>
<br>
I.e., the question is, how does 'is' work on delayed objects? I guess<br>
it has to force the promise and walk the proxy chain in each input and<br>
then do an 'is' on the base objects? </blockquote><div><br></div><div>You've explained the semantics exactly. That's not confusing at all. If the next line after creating delayed 'value' is to check it against something (whether for equality or identity) then obviously it was pointless to make it delayed. But that's not the only pattern: </div><div> </div></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">value = delayed some_dict.get(expensive_key_lookup(),</font></div><div><font face="monospace, monospace"> expensive_default_calculation())</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">... lots more code ...</font></div><div><div class="gmail_extra"><div class="gmail_quote"><font face="monospace, monospace"># OK, there might come a time to concretize</font></div></div><div class="gmail_extra"><div class="gmail_quote"></div></div></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><font face="monospace, monospace">if some_unrelated_thing and value is None: </font></div><div><span style="font-family:monospace,monospace"> # do this, but only concretize 'value' if </span></div><div><span style="font-family:monospace,monospace"> # the first part of conjunction was truthy</span><br></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div><br></div></div></div></blockquote><div class="gmail_extra"><div><br></div>-- <br><div class="gmail_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>
</div></div>