Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%time and %timeit won't work with multiple line function calls #5940

Closed
peter-ch opened this issue Jun 3, 2014 · 4 comments
Closed

%time and %timeit won't work with multiple line function calls #5940

peter-ch opened this issue Jun 3, 2014 · 4 comments
Milestone

Comments

@peter-ch
Copy link

peter-ch commented Jun 3, 2014

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

I'm using IPython 2.1 on Python 2.7

@minrk
Copy link
Member

minrk commented Jun 3, 2014

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

@peter-ch
Copy link
Author

peter-ch commented Jun 3, 2014

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.

@takluyver
Copy link
Member

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)

@minrk minrk added this to the no action milestone Jun 3, 2014
@suberlak
Copy link

suberlak commented Dec 4, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants