I haven\'t seen an established way to memoize a function that takes key-word arguments, i.e. something of type
def f(*args, **kwargs)
since
dicts can be in arbitrary order, so there's no guarantee that the latter will work. Use sorted(kwargs.items()) to get it sorted by key first.
sorted(kwargs.items())