Skip to content

%timeit on command line doesn't recognize [1..10] syntax #797

Closed

Description

@jasongrout
sage: %time [1..10]
------------------------------------------------------------
   File "<timed exec>", line 1
     [1..10]
          ^
<type 'exceptions.SyntaxError'>: invalid syntax

sage: %timeit [1..10]
------------------------------------------------------------
   File "<magic-timeit>", line 6
     [1..10]
          ^
<type 'exceptions.SyntaxError'>: invalid syntax

sage: %timeit xrange(11)
1000000 loops, best of 3: 392 ns per loop

Component: user interface

Keywords: timeit ipython

Author: Mike Hansen

Reviewer: Jason Grout

Merged: sage-4.3.1.rc1

Issue created by migration from https://trac.sagemath.org/ticket/797

Activity

  1. added this to the sage-2.9 milestone on Oct 3, 2007
  2. jasongrout commented on Jan 14, 2009

    @jasongrout
    MemberAuthor
    comment:3

    The workaround now is to use the timeit command, which does send things to the preparser.

    sage: timeit('[1..10]')
    625 loops, best of 3: 220 µs per loop
    
  3. williamstein commented on Jan 14, 2009

    @williamstein
    Contributor
    comment:5

    Just because there is a workaround doesn't mean this should be closed. I reported this problem to Fernando Perez of Ipython and he "admitted" that it is a bug, and was working on fixing it at that last sage days. I'm re-opening this.

    By the way, it's generally very bad for anybody but me or Michael Abshoff to close tickets on trac!

  4. jasongrout commented on Jan 14, 2009

    @jasongrout
    MemberAuthor
    comment:6

    I only closed it after mabshoff gave his okay on IRC. I guess I should have posted the IRC log.

  5. 19 remaining items

  6. mwhansen commented on Jan 17, 2010

    @mwhansen
    Contributor

    Attachment: trac_797.patch.gz

  7. mwhansen commented on Jan 17, 2010

    @mwhansen
    Contributor

    Author: Mike Hansen

  8. mwhansen commented on Jan 17, 2010

    @mwhansen
    Contributor
    comment:21

    I've put a patch up which implements the expose_magic idea.

  9. jasongrout commented on Jan 17, 2010

    @jasongrout
    MemberAuthor
    comment:22

    Looks great! Positive review to Mike's patch. Only apply Mike's patch (to the local/bin repository!)

  10. rlmill commented on Jan 18, 2010

    rlmillmannequin
    Mannequin

    Merged: sage-4.3.1.rc1

  11. rlmill commented on Jan 18, 2010

    rlmillmannequin
    Mannequin

    Reviewer: Jason Grout

  12. added a commit that references this issue on Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions