def memoize(func):
  """
  Decorator for unerasable memoization based on function arguments, for
  functions without keyword arguments.
  """
  class Memoizer(dict):
    def __missing__(self, args):
      val = func(*args)
      self[args] = val
      return val
  memory = Memoizer()
  @wraps(func)
  def wrapper(*args):
    return memory[args]
  return wrapper
Decorator for unerasable memoization based on function arguments, for
  functions without keyword arguments.