HOW TO: Find SLOW Code (3 ways in Python)

Опубликовано: 02 Август 2026
на канале: chinamatt
373
5

Here are 3 ways to find where your code is slowing you down.
1. %timeit -n 10 -r 2 myFunc( )
change the numbers as you like.
2. %prun myFunc( )
3. %lprun -f myFunc myFunc()
Activate using: %load_ext line_profiler

Install line_profiler by following this GitHub comment:
https://github.com/rkern/line_profile...

If there is still an error, you might need to install Visual Studio from Microsoft (which I will link below):
https://visualstudio.microsoft.com/th...

After installation, remember to restart your pc, and you should be able to pip install line profiler.