Top-rated recipes tagged "lazy_evaluation" but not "calculus"http://code.activestate.com/recipes/tags/lazy_evaluation-calculus/top/2009-04-26T18:10:55-07:00ActiveState Code Recipeslazy property (Python)
2009-04-26T18:10:55-07:00Sridhar Ratnakumarhttp://code.activestate.com/recipes/users/4169511/http://code.activestate.com/recipes/576720-lazy-property/
<p style="color: grey">
Python
recipe 576720
by <a href="/recipes/users/4169511/">Sridhar Ratnakumar</a>
(<a href="/recipes/tags/evaluation/">evaluation</a>, <a href="/recipes/tags/lazy/">lazy</a>, <a href="/recipes/tags/lazy_evaluation/">lazy_evaluation</a>).
Revision 6.
</p>
<p>Python does not have lazy evaluation syntax features built-in, but fortunately decorators can be used with new-style classes to emulate such a feature. There are cases where one wants <code>foo.property</code> to return the actual property whose calculation takes significant amount of time.</p>
<p>This recipe adapts the existing <code>property</code> to provide a <code>lazypropery</code> decorator that does this.</p>
<p>See the first comment below for an example usage.</p>
<p>Also see: <a href="http://en.wikipedia.org/wiki/Lazy_initialization">lazy initialization</a></p>
Lazy, recursive generator function (Python)
2008-12-14T10:04:29-08:00Don Sawatzkyhttp://code.activestate.com/recipes/users/4168423/http://code.activestate.com/recipes/576585-lazy-recursive-generator-function/
<p style="color: grey">
Python
recipe 576585
by <a href="/recipes/users/4168423/">Don Sawatzky</a>
(<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/lazy_evaluation/">lazy_evaluation</a>, <a href="/recipes/tags/recursion/">recursion</a>).
Revision 4.
</p>
<p>This procedure was proposed as a challenge to Python and other languages as the most concise coding. See Icon programming on the web. This is a lazy, recursive generator. It can be implemented several ways in Python with lists, iteration, and recursion. However, the lists increase in size exponentially with each iteration and recursion plus they are saved in every recursion. This recipe develops a lazy generator function.</p>