Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:06

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