#797: %timeit doesn't recognize [1..10] syntax
----------------------------+-----------------------------------------------
 Reporter:  jason           |        Owner:  was       
     Type:  defect          |       Status:  reopened  
 Priority:  minor           |    Milestone:  sage-3.4.1
Component:  user interface  |   Resolution:            
 Keywords:                  |  
----------------------------+-----------------------------------------------
Changes (by SimonKing):

  * summary:  timeit doesn't recognize [1..10] syntax => %timeit doesn't
              recognize [1..10] syntax

Comment:

 I somehow got the impression that it is an issue with preparsing, for the
 following reason:
 {{{
 sage: timeit('[1..10]',preparse=False)
 ------------------------------------------------------------
    File "<magic-timeit>", line 6
      [1..10]
           ^
 SyntaxError: invalid syntax
 }}}

 This is the same error as in
 {{{
 sage: %timeit [1..10]
 }}}

 In the code, by default preparsing should be done; namely, in
 `sage_timer.py` it says
 {{{
 def sage_timeit(stmt, globals, preparse=None, number = 0, repeat = 3,
 precision = 3):
 ...
     if preparse is None:
         preparse = interpreter.do_preparse
 }}}

 Now, we also have
 {{{
 sage: from sage.misc import interpreter
 sage: interpreter.do_preparse
 True
 }}}

 So, it *should* be with preparsing.

 For testing, I inserted a line in the code that prints the value of
 `preparse`.

 The curious thing is that this line is executed when doing
 `timeit('[1..10]')` or `timeit.eval('[1..10]')`, but it is ''not''
 executed when doing `%timeit [1..10]`.

 I was just told that `%timeit ...` should do the same as
 `timeit.eval('...')`, but apparently it doesn't. So, perhaps it is a
 problem with the `%`?

 Can you tell me where the behaviour of `%` is defined?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/797#comment:9>
Sage <http://sagemath.org/>
Sage - Open Source Mathematical Software: Building the Car Instead of 
Reinventing the Wheel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to