# Path: ch07decorator/my_time_decorator.py
# def clock(func):
#     @functools.wraps(func)
#     def clocked(*args, **kwargs):
#         t0 = time.perf_counter()
#         result = func(*args, **kwargs)
#         elapsed = time.perf_counter() - t0
#         name = func.__name__
#         arg_str = ', '.join(repr(arg) for arg in args)
#         print('[%0.8fs] %s(%s) -> %r' % (elapsed, name, arg_str, result))
#         return result
# 
#     return clocked


import functools
from ch07decorator.my_time_decorator import clock
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Topic: functools.lru_cache做备忘
被 lru_cache 装饰的函数，它的所有参数都必须是可散列的。
"""



@functools.lru_cache()

# Path: ch07decorator/my_time_decorator.py
# def clock(func):
#     @functools.wraps(func)
#     def clocked(*args, **kwargs):
#         t0 = time.perf_counter()
#         result = func(*args, **kwargs)
#         elapsed = time.perf_counter() - t0
#         name = func.__name__
#         arg_str = ', '.join(repr(arg) for arg in args)
#         print('[%0.8fs] %s(%s) -> %r' % (elapsed, name, arg_str, result))
#         return result
# 
#     return clocked


# Path: ch07decorator/my_lru_cache.py
import functools
from ch07decorator.my_time_decorator import clock

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Topic: functools.lru_cache做备忘
被 lru_cache 装饰的函数，它的所有参数都必须是可散列的。
"""



@functools.lru_cache()

@clock