There are optimizations that you can make to have your notebook scripts run more efficiently. The optimizations are script language dependent. We have covered using Python and R scripts in our notebooks and will cover optimizations that can be made for those two languages.
Jupyter does support additional languages, such as Scala and Spark. The other languages have their own optimization tools and strategies.
Performance tuning your Python scripts can be done using several tools:
timeit
- Python regular expressions
- String handling
- Loop optimizations
hotshot
profiling
The timeit
function in Python takes a line of code and determines how long it takes to execute. You can also repeatedly execute the same script to see if there are start-up issues that need to be addressed.
timeit
is used in this manner:
import timeitt = timeit.Timer("myfunction('Hello World')", "import myfunction") t.timeit() 3.32132323232...