Ipython: %time and %timeit won't work with multiple line function calls

Created on 3 Jun 2014  路  4Comments  路  Source: ipython/ipython

This screenshot explains it best. http://i.imgur.com/omp3mSW.png

I'm using IPython 2.1 on Python 2.7

Most helpful comment

Yes, a cell magic has to be the only thing in that cell.

You can also use explicit line continuations to do it with a line magic:

%timeit f(1, \
          2, \
          3)

All 4 comments

You can use %%time or %%timeit cell magics for multi-line blocks.

Thanks. I tried %%timeit already, but the call was on the same line and there was still an error. I tried moving it down now and it works. But it says "SyntaxError: invalid syntax" if a comment line precedes the one with %%timeit.

Yes, a cell magic has to be the only thing in that cell.

You can also use explicit line continuations to do it with a line magic:

%timeit f(1, \
          2, \
          3)

I got that error because there were two spaces after %%time (!). I don't know if this is a known issue (?)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  4Comments

okomarov picture okomarov  路  3Comments

ghost picture ghost  路  4Comments

sataliulan picture sataliulan  路  4Comments

quchunguang picture quchunguang  路  3Comments