

Minimalistic Memoization (Python, 16 lines) - jacquesm
http://code.activestate.com/recipes/577219-minimalistic-memoization/

======
ashish_0x90
The Function memoize looks like a python decorator to
me(<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-
memo...](http://code.activestate.com/recipes/577219-minimalistic-
memoization/?c=10628#c1)

------
Semiapies
Be sure to crank up your recursion limit to at least 1459 if you want the
posted example to work.

------
mc_
Not having worked much with Python, what's the * next to x in lines 9 and 11
about?

~~~
1331
<http://docs.python.org/reference/expressions.html#calls>

Line 9: A formal parameter using the syntax * identifier receives a tuple
containing any excess positional arguments.

Line 11: When the syntax * expression appears in the function call, expression
evaluates to a sequence, the elements of which are treated as if they were the
positional arguments.

