#17808: Preparse integers as strings
-------------------------------------+-------------------------------------
Reporter: jdemeyer | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-6.6
Component: misc | Resolution:
Keywords: | Merged in:
Authors: Jeroen Demeyer | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/jdemeyer/ticket/17808 | 533af4ce9ae65f71d38177052fccb28cc69234e7
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
I would think the slow-down for small integers makes the proposed changes
very unattractive. The whole idea of preparsing `100` as `Integer(100)` is
that in the AST and the generated byte code, the constant `100` is already
stored as a numerical one, and hence conversion is much faster.
For instance, in code like:
{{{
sage: %timeit
L=[Integer('1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')
for i in range(10000r)]
100 loops, best of 3: 11.4 ms per loop
sage: %timeit
L=[Integer(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
for i in range(10000r)]
100 loops, best of 3: 4.66 ms per loop
}}}
you really start to notice this.
preparse_file mitigates issues like this a little bit by factoring out
numeric constants, so that their conversion doesn't happen in inner loops.
If you want to store your numerical constants as strings in the byte code
and have fast conversion, you should probably store them in hex. It's a
little more work in the preparser, but the result is more compact and
conversion to a numerical constant is truly linear in number of bits.
--
Ticket URL: <http://trac.sagemath.org/ticket/17808#comment:5>
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.