Popular recipes tagged "memoization" but not "generators"http://code.activestate.com/recipes/tags/memoization-generators/2012-08-02T07:27:12-07:00ActiveState Code RecipesProbably the fastest memoization decorator in the world (Python) 2012-08-02T07:27:12-07:00Oren Tiroshhttp://code.activestate.com/recipes/users/2033964/http://code.activestate.com/recipes/578231-probably-the-fastest-memoization-decorator-in-the-/ <p style="color: grey"> Python recipe 578231 by <a href="/recipes/users/2033964/">Oren Tirosh</a> (<a href="/recipes/tags/cache/">cache</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/memo/">memo</a>, <a href="/recipes/tags/memoization/">memoization</a>). </p> <p>With apologies to a certain European brand of beer, this is probably the fastest memoization decorator in the world. Implemented using the __missing__ method in a dict subclass. </p> Simple caching decorator (Python) 2010-12-01T00:43:01-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577479-simple-caching-decorator/ <p style="color: grey"> Python recipe 577479 by <a href="/recipes/users/178123/">Raymond Hettinger</a> (<a href="/recipes/tags/cache/">cache</a>, <a href="/recipes/tags/memoization/">memoization</a>). </p> <p>Memoizing decorator. Has the same API as the functools.lru_cache() in Py3.2 but without the LRU feature, so it takes less memory, runs faster, and doesn't need locks to keep the dictionary in a consistent state.</p> Simple local cache and cache decorator (Python) 2010-12-08T09:06:34-08:00Andrey Nikishaevhttp://code.activestate.com/recipes/users/4176176/http://code.activestate.com/recipes/577492-simple-local-cache-and-cache-decorator/ <p style="color: grey"> Python recipe 577492 by <a href="/recipes/users/4176176/">Andrey Nikishaev</a> (<a href="/recipes/tags/cache/">cache</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/memoization/">memoization</a>, <a href="/recipes/tags/python/">python</a>). </p> <p>Simple local cache. It saves local data in singleton dictionary with convenient interface</p> <h4 id="examples-of-use">Examples of use:</h4> <pre class="prettyprint"><code># Initialize SimpleCache({'data':{'example':'example data'}}) # Getting instance c = SimpleCache.getInstance() c.set('re.reg_exp_compiled',re.compile(r'\W*')) reg_exp = c.get('re.reg_exp_compiled',default=re.compile(r'\W*')) # -------------------------------------------------------------- c = SimpleCache.getInstance() reg_exp = c.getset('re.reg_exp_compiled',re.compile(r'\W*')) # -------------------------------------------------------------- @scache def func1(): return 'OK' </code></pre> Minimalistic Memoization (Python) 2010-05-06T16:59:52-07:00Ahmed El Deebhttp://code.activestate.com/recipes/users/4173897/http://code.activestate.com/recipes/577219-minimalistic-memoization/ <p style="color: grey"> Python recipe 577219 by <a href="/recipes/users/4173897/">Ahmed El Deeb</a> (<a href="/recipes/tags/caching/">caching</a>, <a href="/recipes/tags/memoization/">memoization</a>, <a href="/recipes/tags/recursion/">recursion</a>). </p> <p>Minimalistic Memoization in python, just works, doesn't take care of cleaning up the cache however.</p>