On Mon, Feb 25, 2008 at 9:20 AM, Joel B. Mohler <[EMAIL PROTECTED]> wrote:
>
>
>  On Monday 25 February 2008 10:56, William Stein wrote:
>  > On Mon, Feb 25, 2008 at 7:49 AM, Joel B. Mohler <[EMAIL PROTECTED]>
>  wrote:
>  > >  Hi,
>  > >
>  > >  I just noticed that the timeit short-cut seems more broken than normal
>  > > (at least I think this worked previous to 2.10.2:
>  > >  sage: R.<x>=ZZ[]
>  > >  sage: f=x^2-1
>  > >  sage: timeit f.factor()
>  > >  ------------------------------------------------------------
>  > >    File "<ipython console>", line 1
>  > >      timeit f.factor()
>  > >             ^
>  > >  <type 'exceptions.SyntaxError'>: invalid syntax
>  > >
>  > >  The ipython native %timeit still works though.
>  > >
>  > >  Is this breakage intentional?  trac ticket warranted?
>  >
>  > If enabled Ipython will do automagic and just turn
>  > "timeit foo" into "%timeit foo" if it happens that there
>  > is no timeit symbol defined in the global namespace.
>  > Sage-2.10.2 defines a timeit function which I think
>  > is much better for Sage than the timeit that is builtin
>  > to IPython.  In particular the one in Sage plays very
>  > well with the Sage preparser but the one in Ipython
>  > doesn't.   Also, I think it is easier to pass options (in
>  > my opinion) since the Sage timeit is just a usual function.
>  >
>  > You should use it like any function call,
>  > and pass it a string:
>  >
>  > sage: R.<x>=ZZ[]
>  > sage: f=x^2-1
>  > sage: timeit('f.factor()')
>  > 5 loops, best of 3: 133 µs per loop
>
>  I see.  I'm wondering if it might also be appropriate to define a new 'time'
>  function that works analogously.  It's a bit startling to see these two --

It might be.  I don't like the time function as it is written now, since it's
done with the preparser and doesn't work when it isn't the first thing on
a line, which is annoying.

sage: 2 + 2; time 2 + 2
------------------------------------------------------------
   File "<ipython console>", line 1
     Integer(2) + Integer(2); time Integer(2) + Integer(2)
                                         ^
<type 'exceptions.SyntaxError'>: invalid syntax

Hey, Nick, want to fix that? ;-)

>  time/timeit -- become dis-similar after having been similar.  Although, I
>  suppose they are mostly for power-users who know these nuances.
>
>
>
>  --
>  Joel
>
>  >
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to