-
-
Save kylegibson/6583590 to your computer and use it in GitHub Desktop.
from decorator import decorator | |
from line_profiler import LineProfiler | |
@decorator | |
def profile_each_line(func, *args, **kwargs): | |
profiler = LineProfiler() | |
profiled_func = profiler(func) | |
try: | |
profiled_func(*args, **kwargs) | |
finally: | |
profiler.print_stats() |
@saurabh-kataria: you need to write:
@profile_each_line
def a():
x=np.ones(100000)
b()
def b():
y=np.ones(20000)
a()
in your snippet returns None
(which is what all Python functions return by default), which is why you're getting the error.
I am not able to see the Line Contents. Only the #hits, #time, etc are being shown. The output says
"Could not find file C:\Users\HP\AppData\Local\Temp\ipykernel_24440\670606222.py
Are you sure you are running this program from the same directory that you ran the profiler from?"
It used to work few months ago but suddenly now the above is happening. And I write my scripts in Onedrive with Anaconda Jupyter Lab. Please suggest what might be wrong. There is NO answer anywhere for this problem and I tried every possible way I could think of to solve it from 8 hours! Just to get the Line Contents so that I can begin my actual task of optimizing my code.
I am getting this error:
AttributeError: 'NoneType' object has no attribute '__code__'