Open stenbein opened 2 years ago
Possible partial solution: Decorators which use functools.wraps annotate the function object with wrapped property which points to the wrapped target. Recursively checking for the wrapper and replacing the function in each case correctly profiles the target function. See mock https://github.com/stenbein/memory_profiler/tree/stacked-decorators
Stacking multiple decorators together will result in unexpected behavior. A trivial example:
What I expect to see:
What we actually get:
I realized while checking this that the sample timeit decorator has the same issue and is timing the
@profile
rather than the underlyingto_profile
.