memoization technique - python implementation for http://en.wikipedia.org/wiki/Memoization