[IPython-User] timing Python fragments with %time

Brian Granger ellisonbg@gmail....
Mon Dec 27 11:40:51 CST 2010


Current IPython magics are only single line so putting the code into a
function is the only way of handling this currently.  Sorry...

Cheers,

Brian

On Sat, Dec 25, 2010 at 4:19 PM, Ben Elliston <bje@air.net.au> wrote:
> Hi all.
>
> I'm trying to use the %time command to time fragments of Python code,
> like so:
>
> In [1]: %time for i in range (1000):
>        some_function (i)
>
> It seems that the only way to make this work is to place the loop
> inside a function definition and call that function instead.  Is there
> a better way?
>
> Thanks, Ben
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iD8DBQFNFooDSW2QaNbXMA0RAmuCAJ9rs5xdAtuvUEwvoa9mKUWqnvKLWgCeI03m
> Fcf7lq0W1nxukpc6onhUoV8=
> =p8vL
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>



-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu
ellisonbg@gmail.com


More information about the IPython-User mailing list