You can use the variable _ (saves the last result) after the cell %%timeit -o and assign it to some reusable variable:
In[2]: %%timeit -o A = np.mat('1 2 3; 7 4 9; 5 6 1') np.linalg.inv(A) Out[2]: blabla <TimeitResult : 1 loop, best of 3: 588 Β΅s per loop> In[3]: res = _ In[4]: res Out[4]: <TimeitResult : 1 loop, best of 3: 588 Β΅s per loop>
I donβt think this is a mistake, because the cell mode commands should be the first command in this cell, so you cannot put anything before this command (not even res = ... ).
However, you still need -o , because otherwise the variable _ contains None .
source share