![]() |
Available news archives:
comp.lang.tcl
-
comp.lang.python
-
comp.security.firewalls
-
sci.crypt -
comp.lang.php -
comp.lang.javascript
|
|
comp.lang.python archiveMemoization and encapsulation
From: Steven D'Aprano <steve@REMOVETHIScyber.com.au>
Date: Sat Dec 31 2005 - 05:23:26 CET
I was playing around with simple memoization and came up with something
_cache = {}
when it hit me if I could somehow bind the cache to the function, I could
I tried this:
>>> def func(x):
and it works as expected, but it lacks elegance.
Instead of using a function, I can also use a new-style class as if it
>>> class Func(object):
and again it works, but I can't help feeling it is an abuse of the class
What do folks think? Is there a better way?
-- Steven.Received on Tue Jan 3 03:28:24 2006 |