Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:02

0001 
0002 def cache(function):
0003     cache = {}
0004     def newfunction(*args, **kwargs):
0005         try:
0006             return cache[args, tuple(sorted(kwargs.iteritems()))]
0007         except TypeError:
0008             print(args, tuple(sorted(kwargs.iteritems())))
0009             raise
0010         except KeyError:
0011             cache[args, tuple(sorted(kwargs.iteritems()))] = function(*args, **kwargs)
0012             return newfunction(*args, **kwargs)
0013     newfunction.__name__ = function.__name__
0014     return newfunction