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: |
| 1 | To 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: |