#12239: Better conversion to/from ECL bignums
---------------------------+------------------------------------------------
Reporter: nbruin | Owner: was
Type: enhancement | Status: new
Priority: minor | Milestone: sage-4.8
Component: interfaces | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
---------------------------+------------------------------------------------
Previously, python <-> ECL conversion of bigints went via (decimal!)
string representation. This ticket fixes this. Timings before:
{{{
sage: from sage.libs.ecl import *
sage: i = 10^(10^5)
sage: o = EclObject(i)
sage: timeit('EclObject(i)')
5 loops, best of 3: 331 ms per loop
sage: timeit('o.python()')
25 loops, best of 3: 18.6 ms per loop
}}}
after:
{{{
sage: timeit('EclObject(i)')
625 loops, best of 3: 44.2 µs per loop
sage: timeit('o.python()')
625 loops, best of 3: 4.49 µs per loop
}}}
These conversions will benefit symbolic routines that call maxima via the
binary interface (integrate, limit, sum) but obviously not the ones that
use all-string conversion. Most symbolic work does not involve large
integers anyway.
NOTE: Current implementation copies the bitstring twice for python -> ECL.
In principle this could be avoided but needs reaching into ECL's
internals. The "ecl_big_register" routines are exported, but the other
routines are "static". This is because there are some subtleties with how
ECL avoids GMPs memory reallocation to step in. Therefore, the present
solution is probably the safest. Should this ever become a bottleneck, we
can reconsider.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12239>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.