Hello, I use decorators in my Python project. I tested project with cProfile(profiling). Then, I decide did test with some decorator code fragments. Some results were surprising: import functools import cProfile def decor(func): @functools.wraps(func) def wraps(*args, **kwargs): return func(*args, **kwargs) return wraps @decor def count(g_val): if g_val < 1: print("End") else: count(g_val - 1) cProfile.run('count(102)') OS names: Windows, Linux - x64 Python versions: 3.6.8, 3.4.3 - x64 # cProfile using into the .py file python dec_profile.py End 210 function calls (6 primitive calls) in 0.000 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 :1() 103/1 0.000 0.000 0.000 0.000 timeer.py:10(count) 103/1 0.000 0.000 0.000 0.000 timeer.py:5(wraps) 1 0.000 0.000 0.000 0.000 {built-in method builtins.exec} 1 0.000 0.000 0.000 0.000 {built-in method builtins.print} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} # Instead of 102 used ---> 82, 22, 33, 72 and etc. also gave me strange results like in 102. This behaviour can be changing sometimes, but usually give an incorrect results. import functools import cProfile def decor(func): @functools.wraps(func) def wraps(*args, **kwargs): return func(*args, **kwargs) return wraps @decor def count(g_val): if g_val < 1: print("End") else: count(g_val - 1) count(102) # cProfile using via command line python -m cProfile dec_profile.py End 539 function calls (334 primitive calls) in 0.002 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 :103(release) 1 0.000 0.000 0.000 0.000 :143(__init__) 1 0.000 0.000 0.000 0.000 :147(__enter__) 1 0.000 0.000 0.000 0.000 :151(__exit__) 1 0.000 0.000 0.000 0.000 :157(_get_module_lock) 1 0.000 0.000 0.000 0.000 :176(cb) 1 0.000 0.000 0.000 0.000 :211(_call_with_frames_removed) 26 0.000 0.000 0.000 0.000 :222(_verbose_message) 1 0.000 0.000 0.000 0.000 :307(__init__) 1 0.000 0.000 0.000 0.000 :311(__enter__) 1 0.000 0.000 0.000 0.000 :318(__exit__) 4 0.000 0.000 0.000 0.000 :321() 1 0.000 0.000 0.000 0.000 :35(_new_module) 1 0.000 0.000 0.000 0.000 :369(__init__) 2 0.000 0.000 0.000 0.000 :403(cached) 1 0.000 0.000 0.000 0.000 :416(parent) 1 0.000 0.000 0.000 0.000 :424(has_location) 1 0.000 0.000 0.000 0.000 :504(_init_module_attrs) 1 0.000 0.000 0.000 0.000 :564(module_from_spec) 1 0.000 0.000 0.000 0.000 :58(__init__) 1 0.000 0.000 0.000 0.000 :651(_load_unlocked) 1 0.000 0.000 0.000 0.000 :707(find_spec) 1 0.000 0.000 0.000 0.000 :78(acquire) 1 0.000 0.000 0.000 0.000 :780(find_spec) 3 0.000 0.000 0.000 0.000 :843(__enter__) 3 0.000 0.000 0.000 0.000 :847(__exit__) 1 0.000 0.000 0.001 0.001 :870(_find_spec) 1 0.000 0.000 0.001 0.001 :936(_find_and_load_unlocked) 1 0.000 0.000 0.001 0.001 :966(_find_and_load) 6 0.000 0.000 0.000 0.000 :1080(_path_importer_cache) 1 0.000 0.000 0.001 0.001 :1117(_get_spec) 1 0.000 0.000 0.001 0.001 :1149(find_spec) 1 0.000 0.000 0.000 0.000 :1228(_get_spec) 5 0.000 0.000 0.001 0.000 :1233(find_spec) 2 0.000 0.000 0.000 0.000 :263(cache_from_source) 1 0.000 0.000 0.000 0.000 :361(_get_cached) 5 0.000 0.000 0.000 0.000 :37(_relax_case) 1 0.000 0.000 0.000 0.000 :393(_check_name_wrapper) 1 0.000 0.000 0.000 0.000 :430(_validate_bytecode_header) 1 0.000 0.000 0.000 0.000 :485(_compile_bytecode) 2 0.000 0.000 0.000 0.000 :52(_r_long) 1 0.000 0.000 0.000 0.000 :524(spec_from_file_location) 25 0.000 0.000 0.000 0.000 :57(_path_join) 25 0.000 0.000 0.000 0.000 :59() 2 0.000 0.000 0.000 0.000 :63(_path_split) 1 0.000 0.000 0.000 0.000 :669(create_module) 1 0.000 0.000 0.000 0.000 :672(exec_module) 1 0.000 0.000 0.000 0.000 :743(get_code) 7 0.000 0.000 0.000 0.000 :75(_path_stat) 1 0.000 0.000 0.000 0.000 :800(__init__) 1 0.000 0.000 0.000 0.000 :825(get_filename) 1 0.000 0.000 0.000 0.000 :830(get_data) 1 0.000 0.000 0.000 0.000 :840(path_stats) 1 0.000 0.000 0.000 0.000 :85(_path_is_mode_type) 1 0.000 0.000 0.000 0.000 :94(_path_isfile) 1 0.000 0.000 0.000 0.000 cProfile.py:27(Profile) 1 0.000 0.000 0.000 0.000 cProfile.py:5() 1 0.000 0.000 0.000 0.000 functools.py:44(update_wrapper) 1 0.000 0.000 0.000 0.000 functools.py:74(wraps) 1 0.000 0.000 0.002 0.002 timeer.py:1() 103/1 0.000 0.000 0.000 0.000 timeer.py:10(count) 1 0.000 0.000 0.000 0.000 timeer.py:4(decor) 103/1 0.000 0.000 0.000 0.000 timeer.py:5(wraps) 1 0.000 0.000 0.000 0.000 {built-in method _imp._fix_co_filename} 5 0.000 0.000 0.000 0.000 {built-in method _imp.acquire_lock} 1 0.000 0.000 0.000 0.000 {built-in method _imp.is_builtin} 1 0.000 0.000 0.000 0.000 {built-in method _imp.is_frozen} 5 0.000 0.000 0.000 0.000 {built-in method _imp.release_lock} 2 0.000 0.000 0.000 0.000 {built-in method _thread.allocate_lock} 2 0.000 0.000 0.000 0.000 {built-in method _thread.get_ident} 1 0.000 0.000 0.000 0.000 {built-in method builtins.__build_class__} 1 0.000 0.000 0.000 0.000 {built-in method builtins.any} 2/1 0.000 0.000 0.002 0.002 {built-in method builtins.exec} 13 0.000 0.000 0.000 0.000 {built-in method builtins.getattr} 7 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr} 7 0.000 0.000 0.000 0.000 {built-in method builtins.isinstance} 4 0.000 0.000 0.000 0.000 {built-in method builtins.len} 1 0.000 0.000 0.000 0.000 {built-in method builtins.print} 5 0.000 0.000 0.000 0.000 {built-in method builtins.setattr} 2 0.000 0.000 0.000 0.000 {built-in method from_bytes} 1 0.000 0.000 0.000 0.000 {built-in method marshal.loads} 3 0.000 0.000 0.000 0.000 {built-in method nt.fspath} 2 0.000 0.000 0.000 0.000 {built-in method nt.getcwd} 7 0.000 0.000 0.000 0.000 {built-in method nt.stat} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 1 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects} 2 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} 27 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} 1 0.000 0.000 0.000 0.000 {method 'read' of '_io.FileIO' objects} 9 0.000 0.000 0.000 0.000 {method 'rpartition' of 'str' objects} 2 0.000 0.000 0.000 0.000 {method 'rsplit' of 'str' objects} 52 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects} 1 0.000 0.000 0.000 0.000 {method 'update' of 'dict' objects} Here also interesting results in computation with some factorial estimations: import math import cProfile def fact(n): return sum(1 / math.factorial(n) for n in range(18)) print(cProfile.run('fact(200)')) # cProfile into the .py file python fact.py 42 function calls in 0.000 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 :1() 1 0.000 0.000 0.000 0.000 timeer.py:5(fact) 19 0.000 0.000 0.000 0.000 timeer.py:6() 1 0.000 0.000 0.000 0.000 {built-in method builtins.exec} 1 0.000 0.000 0.000 0.000 {built-in method builtins.sum} 18 0.000 0.000 0.000 0.000 {built-in method math.factorial} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} import math import cProfile def fact(n): print(sum(1 / math.factorial(n) for n in range(18))) fact(200) # cProfile using via command line python -m cProfile fact.py 2.7182818284590455 417 function calls (416 primitive calls) in 0.001 seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 2 0.000 0.000 0.000 0.000 :103(release) 2 0.000 0.000 0.000 0.000 :143(__init__) 2 0.000 0.000 0.000 0.000 :147(__enter__) 2 0.000 0.000 0.000 0.000 :151(__exit__) 2 0.000 0.000 0.000 0.000 :157(_get_module_lock) 2 0.000 0.000 0.000 0.000 :176(cb) 3 0.000 0.000 0.000 0.000 :211(_call_with_frames_removed) 27 0.000 0.000 0.000 0.000 :222(_verbose_message) 1 0.000 0.000 0.000 0.000 :232(_requires_builtin_wrapper) 2 0.000 0.000 0.000 0.000 :307(__init__) 2 0.000 0.000 0.000 0.000 :311(__enter__) 2 0.000 0.000 0.000 0.000 :318(__exit__) 8 0.000 0.000 0.000 0.000 :321() 1 0.000 0.000 0.000 0.000 :35(_new_module) 2 0.000 0.000 0.000 0.000 :369(__init__) 2 0.000 0.000 0.000 0.000 :403(cached) 2 0.000 0.000 0.000 0.000 :416(parent) 2 0.000 0.000 0.000 0.000 :424(has_location) 1 0.000 0.000 0.000 0.000 :433(spec_from_loader) 2 0.000 0.000 0.000 0.000 :504(_init_module_attrs) 2 0.000 0.000 0.000 0.000 :564(module_from_spec) 2 0.000 0.000 0.000 0.000 :58(__init__) 2 0.000 0.000 0.000 0.000 :651(_load_unlocked) 2 0.000 0.000 0.000 0.000 :707(find_spec) 1 0.000 0.000 0.000 0.000 :728(create_module) 1 0.000 0.000 0.000 0.000 :736(exec_module) 1 0.000 0.000 0.000 0.000 :753(is_package) 2 0.000 0.000 0.000 0.000 :78(acquire) 1 0.000 0.000 0.000 0.000 :780(find_spec) 4 0.000 0.000 0.000 0.000 :843(__enter__) 4 0.000 0.000 0.000 0.000 :847(__exit__) 2 0.000 0.000 0.001 0.000 :870(_find_spec) 2 0.000 0.000 0.001 0.001 :936(_find_and_load_unlocked) 2 0.000 0.000 0.001 0.001 :966(_find_and_load) 6 0.000 0.000 0.000 0.000 :1080(_path_importer_cache) 1 0.000 0.000 0.001 0.001 :1117(_get_spec) 1 0.000 0.000 0.001 0.001 :1149(find_spec) 1 0.000 0.000 0.000 0.000 :1228(_get_spec) 5 0.000 0.000 0.001 0.000 :1233(find_spec) 2 0.000 0.000 0.000 0.000 :263(cache_from_source) 1 0.000 0.000 0.000 0.000 :361(_get_cached) 5 0.000 0.000 0.000 0.000 :37(_relax_case) 1 0.000 0.000 0.000 0.000 :393(_check_name_wrapper) 1 0.000 0.000 0.000 0.000 :430(_validate_bytecode_header) 1 0.000 0.000 0.000 0.000 :485(_compile_bytecode) 2 0.000 0.000 0.000 0.000 :52(_r_long) 1 0.000 0.000 0.000 0.000 :524(spec_from_file_location) 25 0.000 0.000 0.000 0.000 :57(_path_join) 25 0.000 0.000 0.000 0.000 :59() 2 0.000 0.000 0.000 0.000 :63(_path_split) 1 0.000 0.000 0.000 0.000 :669(create_module) 1 0.000 0.000 0.000 0.000 :672(exec_module) 1 0.000 0.000 0.000 0.000 :743(get_code) 7 0.000 0.000 0.000 0.000 :75(_path_stat) 1 0.000 0.000 0.000 0.000 :800(__init__) 1 0.000 0.000 0.000 0.000 :825(get_filename) 1 0.000 0.000 0.000 0.000 :830(get_data) 1 0.000 0.000 0.000 0.000 :840(path_stats) 1 0.000 0.000 0.000 0.000 :85(_path_is_mode_type) 1 0.000 0.000 0.000 0.000 :94(_path_isfile) 1 0.000 0.000 0.000 0.000 cProfile.py:27(Profile) 1 0.000 0.000 0.000 0.000 cProfile.py:5() 1 0.000 0.000 0.001 0.001 timeer.py:1() 1 0.000 0.000 0.000 0.000 timeer.py:4(fact) 19 0.000 0.000 0.000 0.000 timeer.py:5() 1 0.000 0.000 0.000 0.000 {built-in method _imp._fix_co_filename} 8 0.000 0.000 0.000 0.000 {built-in method _imp.acquire_lock} 1 0.000 0.000 0.000 0.000 {built-in method _imp.create_builtin} 1 0.000 0.000 0.000 0.000 {built-in method _imp.exec_builtin} 2 0.000 0.000 0.000 0.000 {built-in method _imp.is_builtin} 1 0.000 0.000 0.000 0.000 {built-in method _imp.is_frozen} 8 0.000 0.000 0.000 0.000 {built-in method _imp.release_lock} 4 0.000 0.000 0.000 0.000 {built-in method _thread.allocate_lock} 4 0.000 0.000 0.000 0.000 {built-in method _thread.get_ident} 1 0.000 0.000 0.000 0.000 {built-in method builtins.__build_class__} 2 0.000 0.000 0.000 0.000 {built-in method builtins.any} 2/1 0.000 0.000 0.001 0.001 {built-in method builtins.exec} 10 0.000 0.000 0.000 0.000 {built-in method builtins.getattr} 11 0.000 0.000 0.000 0.000 {built-in method builtins.hasattr} 7 0.000 0.000 0.000 0.000 {built-in method builtins.isinstance} 4 0.000 0.000 0.000 0.000 {built-in method builtins.len} 1 0.000 0.000 0.000 0.000 {built-in method builtins.print} 1 0.000 0.000 0.000 0.000 {built-in method builtins.sum} 2 0.000 0.000 0.000 0.000 {built-in method from_bytes} 1 0.000 0.000 0.000 0.000 {built-in method marshal.loads} 18 0.000 0.000 0.000 0.000 {built-in method math.factorial} 3 0.000 0.000 0.000 0.000 {built-in method nt.fspath} 2 0.000 0.000 0.000 0.000 {built-in method nt.getcwd} 7 0.000 0.000 0.000 0.000 {built-in method nt.stat} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 1 0.000 0.000 0.000 0.000 {method 'endswith' of 'str' objects} 4 0.000 0.000 0.000 0.000 {method 'get' of 'dict' objects} 27 0.000 0.000 0.000 0.000 {method 'join' of 'str' objects} 1 0.000 0.000 0.000 0.000 {method 'read' of '_io.FileIO' objects} 11 0.000 0.000 0.000 0.000 {method 'rpartition' of 'str' objects} 2 0.000 0.000 0.000 0.000 {method 'rsplit' of 'str' objects} 52 0.000 0.000 0.000 0.000 {method 'rstrip' of 'str' objects} In cProfile documentation isn't talking about command line behaviour difference.