#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 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`.
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 that users should know something funny is going on:
{{{
sage: 0100
/usr/local/src/sage-git/local/lib/python2.7/site-
packages/IPython/core/interactiveshell.py:2883: DeprecationWarning: use 0o
as octal prefix instead of 0
See http://trac.sagemath.org/17413 for details.
exec(code_obj, self.user_global_ns, self.user_ns)
64
}}}
--
--
Ticket URL: <http://trac.sagemath.org/ticket/17808#comment:2>
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.