I want to try the https://jiffyclub.github.io/snakeviz/ SnakeViz Jupyter extension for profiling Python code right inside the Jupyter notebook!
!python3 -m pip install snakeviz
%load_ext snakeviz
Let's try it!
def carre1(i):
return i**2
N = 10000
%snakeviz sum(carre1(i) for i in range(N))
Let's try this too!
%%snakeviz
x = 0
for i in range(N+1):
x += i**2
print(f"Sum i**2 for i=0 to {N} = {x}")
I think it's quite useful, and well designed.
It's completely "over kill" for any teaching at bac-2/bac+3 level (in France), but I keep it in mind, in case I need to use it for my own work.