Skip to content

Instantly share code, notes, and snippets.

@VivienGiraud
Last active September 13, 2021 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VivienGiraud/4e5f58adc1318da304b26780cbb52873 to your computer and use it in GitHub Desktop.
Save VivienGiraud/4e5f58adc1318da304b26780cbb52873 to your computer and use it in GitHub Desktop.
Add timing decorator
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def flag(code):
OFFSET = ord('🇦') - ord('A')
return chr(ord(code[0]) + OFFSET) + chr(ord(code[1]) + OFFSET)
print(flag('FR'))
🇫🇷
from functools import wraps
import time
def timing(f):
@wraps(f)
def wrap(*args, **kwargs):
time1 = time.time()
ret = f(*args, **kwargs)
time2 = time.time()
logger.info(f'{f.__name__:s} function took {(time2 - time1):.2f} s')
return ret
return wrap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment