Popular recipes tagged "cache" and "decorators"http://code.activestate.com/recipes/tags/cache+decorators/popular/2012-01-06T02:24:08-08:00ActiveState Code RecipesCached Class (Python)
2012-01-06T02:24:08-08:00Peter Donishttp://code.activestate.com/recipes/users/4180313/http://code.activestate.com/recipes/577998-cached-class/
<p style="color: grey">
Python
recipe 577998
by <a href="/recipes/users/4180313/">Peter Donis</a>
(<a href="/recipes/tags/cache/">cache</a>, <a href="/recipes/tags/decorators/">decorators</a>).
Revision 5.
</p>
<p>A class decorator that ensures that only one instance of
the class exists for each distinct set of constructor
arguments.</p>
<p>Note that if a decorated class is subclassed, each subclass is cached separately. (This is because each cached subclass is a different <code>cls</code> argument to the <code>__new__</code> method.)</p>