How to memoize **kwargs?

前端 未结 5 1182
情深已故
情深已故 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:29

    It's similar to what EMS said, but the best way would be:

    key = cPickle.dumps((*args, **kwargs))
    

    I've been doing a lot of research and testing for memorization with decorators, and this is the best method I've found so far.

提交回复
热议问题