why memoizing is faster
Terry Reedy
tjreedy at udel.edu
Sat Mar 26 02:10:42 EDT 2011
On 3/26/2011 12:17 AM, Stefan Behnel wrote:
> Not "restarted" in the sense that it gets cleaned up, though. The above
> simply passes an explicit value for it that will be used for the single
> call.
Which satisfies the time test need, but...
> Future calls won't be affected.
Good point. If one does fib(10000) and wants to dump the cache without
dumping all references to the function object, one can currently do
fib_iter.__kwdefaults__['_cache'] = [0,1]
to truly reset the cache, at least with CPython.
--
Terry Jan Reedy
More information about the Python-list
mailing list