File size: 449 Bytes
95a3fe5
 
 
c98d640
 
 
 
 
 
 
 
 
 
95a3fe5
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import time


def conditonal_decorator(dec, condition):
    def decorator(func):
        if not condition:
            return func

        return dec(func)

    return decorator


def time_function(f):
    def wrapper(*args, **kwargs):
        begin = time.time()
        result = f(*args, **kwargs)
        end = time.time()
        print(f"function {f.__name__} took: {end - begin} seconds to execute.")
        return result

    return wrapper