text: def _memoize(func, *args, **kw):
      if kw:  # frozenset is used to ensure hashability
          key = args, frozenset(kw.items())
      else:
          key = args
      cache = func.cache  # attribute added by memoize
      if key not in cache:
          cache[key] = func(*args, **kw)
      return cache[key]
  