ch08, 09, 10: example files

This commit is contained in:
Luciano Ramalho
2020-06-11 14:58:15 -03:00
parent 42861b64d8
commit bf4a2be8b9
111 changed files with 4707 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import time
def clock(func):
def clocked(*args): # <1>
t0 = time.perf_counter()
result = func(*args) # <2>
elapsed = time.perf_counter() - t0
name = func.__name__
arg_str = ', '.join(repr(arg) for arg in args)
print(f'[{elapsed:0.8f}s] {name}({arg_str}) -> {result!r}')
return result
return clocked # <3>