3 ms·
The Function memoize looks like a python decorator to me(http://www.python.org/dev/peps/pep-0318/ http://www.python.org/dev/peps/pep-0318/ ), IMHO, code can be
by ashish_0x90 16y ago
The Function memoize looks like a python decorator to me(http://www.python.org/dev/peps/pep-0318/ http://www.python.org/dev/peps/pep-0318/ ),
IMHO, code can be more pythonic and still minimalistic if we declare fib this way using decorators
@memoize
fib(n)
also we don't need to use the line : fib = memoize(fib)
after this change
I don't know though if decorators were not used on purpose..
Update: I have commented updated code on recipe's page - http://code.activestate.com/recipes/577219-minimalistic-memoization/?c=10628#c1 http://code.activestate.com/recipes/577219-minimalistic-memo...