#17808: Preparse integers as strings
-------------------------------+------------------------
Reporter: jdemeyer | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.6
Component: misc | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-------------------------------+------------------------
Description changed by jdemeyer:
Old description:
> Currently we have
> {{{
> sage: print preparse("100")
> Integer(100)
> sage: preparse("100.0")
> RealNumber('100.0')
> }}}
> but the first could be changed to
> {{{
> sage: print preparse("100")
> Integer('100')
> }}}
>
> This has two advantages:
>
> 1. it would also be a lot faster since MPIR parses large string constants
> faster than Python:
> {{{
> sage: s="1" + "0"*10000
> sage: timeit("""eval("%s")""" % s)
> 625 loops, best of 3: 751 µs per loop
> sage: timeit("""eval('Integer("%s")')""" % s)
> 625 loops, best of 3: 151 µs per loop
> }}}
>
> 2. It solves #17807: thanks to #17413, entering `0100` will give a
> deprecation warning so at users should know something funny is going on
> when they enter `0100`.
New description:
Currently we have
{{{
sage: print preparse("100")
Integer(100)
sage: preparse("100.0")
RealNumber('100.0')
}}}
but the first could be changed to
{{{
sage: print preparse("100")
Integer('100')
}}}
This has two advantages:
1. it would be a lot faster for large numbers since MPIR is asymptotically
faster than Python:
{{{
sage: s="1" + "0"*10000
sage: timeit("""eval('Integer(%s)')""" % s)
625 loops, best of 3: 761 µs per loop
sage: timeit("""eval('Integer("%s")')""" % s)
625 loops, best of 3: 151 µs per loop
}}}
For small numbers, there is a slight slowdown though:
{{{
sage: s="1000"
sage: timeit("""eval('Integer(%s)')""" % s)
625 loops, best of 3: 9.56 µs per loop
sage: timeit("""eval('Integer("%s")')""" % s)
625 loops, best of 3: 11 µs per loop
}}}
2. It solves #17807: thanks to #17413, entering `0100` will give a
deprecation warning so at users should know something funny is going on
when they enter `0100`.
--
--
Ticket URL: <http://trac.sagemath.org/ticket/17808#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.