Changes between Version 2 and Version 9 of Ticket #17808


Ignore:
Timestamp:
Feb 24, 2015, 2:38:47 PM (8 years ago)
Author:
jdemeyer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17808

    • Property Status changed from new to needs_work
    • Property Authors changed from to Jeroen Demeyer
    • Property Summary changed from Preparse integers as strings to Preparse old-style octals as strings
    • Property Branch changed from to u/jdemeyer/ticket/17808
    • Property Commit changed from to 533af4ce9ae65f71d38177052fccb28cc69234e7
  • Ticket #17808 – Description

    v2 v9  
    1 Currently we have
    2 {{{
    3 sage: print preparse("100")
    4 Integer(100)
    5 sage: preparse("100.0")
    6 RealNumber('100.0')
    7 }}}
    8 but the first could be changed to
    9 {{{
    10 sage: print preparse("100")
    11 Integer('100')
    12 }}}
    13 
    14 This has two advantages:
    15 
    16 1. it would be a lot faster for large numbers since MPIR is asymptotically faster than Python:
    17 {{{
    18 sage: s="1" + "0"*10000
    19 sage: timeit("""eval('Integer(%s)')""" % s)
    20 625 loops, best of 3: 761 µs per loop
    21 sage: timeit("""eval('Integer("%s")')""" % s)
    22 625 loops, best of 3: 151 µs per loop
    23 }}}
    24 For small numbers, there is a slight slowdown though:
    25 {{{
    26 sage: s="1000"
    27 sage: timeit("""eval('Integer(%s)')""" % s)
    28 625 loops, best of 3: 9.56 µs per loop
    29 sage: timeit("""eval('Integer("%s")')""" % s)
    30 625 loops, best of 3: 11 µs per loop
    31 }}}
    32 
    33 2. It solves #17807: thanks to #17413, entering `0100` will give a deprecation warning so that users should know something funny is going on:
     1To solve #17807, we preparse `0100` as `Integer('0100')` instead of `Integer(0100)`: thanks to #17413, this will give a deprecation warning so that users should know something funny is going on:
    342{{{
    353sage: 0100