import six


def _default_key(func, args, kwargs):
  """Get a key name based on function, arguments and keyword arguments."""
  # Use unicode instead of str where possible. This makes it less likely to
  # have false misses.
  args = tuple(arg if not isinstance(arg, str) else str(arg) for arg in args)

  kwargs = {
      key: value if not isinstance(value, str) else str(value)
      for key, value in six.iteritems(kwargs)
  }

  return 'memoize:%s' % [func.__name__, args, sorted(kwargs.items())]