How to memoize **kwargs?

前端 未结 5 1193
情深已故
情深已故 2020-12-28 17:51

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

5条回答
  •  滥情空心
    2020-12-28 18:22

    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.

提交回复
热议问题