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

Показать описание
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:
If there is still an error, you might need to install Visual Studio from Microsoft (which I will link below):
After installation, remember to restart your pc, and you should be able to pip install line profiler.
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:
If there is still an error, you might need to install Visual Studio from Microsoft (which I will link below):
After installation, remember to restart your pc, and you should be able to pip install line profiler.