30. Line Profiler Usage
line_profiler measures execution time line by line in functions.
Example
pip install line-profiler
@profile
def work():
total = 0
for i in range(10**6):
total += i
return total
Run with:
kernprof -l -v script.py
Wrap-Up
Line profiling helps pinpoint slow lines within functions.