regarding memoize function
ankitks.mital at gmail.com
ankitks.mital at gmail.com
Thu Apr 3 19:33:41 EDT 2008
I saw example of memoize function...here is snippet
def memoize(fn, slot):
def memoized_fn(obj, *args):
if hasattr(obj, slot):
return getattr(obj, slot)
else:
val = fn(obj, *args)
setattr(obj, slot, val)
return val
return memoized_fn
and I am really clueless, about what it does. I know in general we try
to keep computed values for future usage. But I am having hard-time
visualizing it.
What is obj here? and what does *args means?
Thanks
More information about the Python-list
mailing list