Thanks, that made things very clear. I like that technique for adding memoization via the parameter. That is clever. It would be nice if there were a way to have multiple functions close over a shared local variable in Python, like let-binding in lisp.