pyutils / line_profiler

Line-by-line profiling for Python
Other
2.62k stars 119 forks source link

Profiling a decorated function #167

Open lagru opened 1 year ago

lagru commented 1 year ago

In https://github.com/scikit-image/scikit-image/issues/6499 we noticed that using LineProfiler().add_function(decorated_func) on a decorated function will trace the decorator and not the decorated function. While this may not necessarily be a bug on line_profiler's side we are still interested in discussing how to best approach this.

lagru commented 1 year ago

As @jni suggest's a solution might be to react to the presence of a __wrapped__ attribute on the function itself. A warning that suggests a solution might go a long way in alleviating this edge case already.

Erotemic commented 1 year ago

I like the idea. A good place to start would be to simply introduce the warning.