'make a hashable key out of args and kwargs'

def _make_key(self, *args, **kwargs):

    def fixitems(items):
        ret = []
        for (k, v) in items:
            try:
                v = tuple(v)
            except Exception:
                pass
            ret.append((k, v))
        return tuple(ret)
    def fixlist(args):
        ret = []
        for a in args:
            if iterable(a):
                a = tuple(a)
            ret.append(a)
        return tuple(ret)
    key = (fixlist(args), fixitems(six.iteritems(kwargs)))
    return key
