[IPython-dev] Feature request/how?

Fernando.Perez at colorado.edu Fernando.Perez at colorado.edu
Tue Feb 22 14:05:16 EST 2005


Quoting Charles Moad <cmoad at indiana.edu>:

> 	First of all, thanks for the code.  I am getting unexpected results
> however.  For example, "%time time.sleep(5)" shows "Call time: 0.00 s."
>   I also have xmlrpc calls that take about 60 seconds that show a call
> time of about 0.04 s.  Are we thinking of different things?

This is expected: the code I gave you uses genutils.clock(), which is written
(at least on Unix) to report only true CPU time.  A sleep() call doesn't
consume almost any cpu time at all.  Feel free to make a modified version of
this function which uses other timing routines from the time module if you want
wall clock time.  As far as I'm concerned, reporting wall clock time is in most
cases a bug, since it's completely context dependent.  But there are valid
cases for wanting it, so you could for example add a -w switch to this function
to use a wall clock instead.

> 	Is it not possible to include assignment operators as well?  Only
> simple expressions seem to work.

It's possible, but you'll have to make the code a bit more complicated.  You
can't return anything, since an assignment is a statement, and not an
expression.  I don't have time right now to work on coding all the
alternatives, but if you want to do so, read up on compile, exec and eval. 
Those are the three calls you'll need to combine to make it work.

Regards,

f




More information about the IPython-dev mailing list