#13257: Coercion from `ZZ['x']` to `Integers(n)['x']` is VERY slow
------------------------------------+---------------------------------------
Reporter: jlopez | Owner: robertwb
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.7
Component: coercion | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Travis Scrimshaw | Merged in:
Dependencies: | Stopgaps:
------------------------------------+---------------------------------------
Changes (by {'newvalue': u'Travis Scrimshaw', 'oldvalue': ''}):
* status: new => needs_review
* author: => Travis Scrimshaw
Comment:
Well, I should say that's where it used to be...it's now in
`polynomial_ring.py`.
Something even more scary to me, this did not scale linearly with `n`:
{{{
sage: a = ZZ['x'](range(30000))
sage: R = Integers(3)['x']
sage: %time L = R(a)
CPU times: user 4.48 s, sys: 0.03 s, total: 4.52 s
Wall time: 4.61 s
sage: a = ZZ['x'](range(60000))
sage: %time L = R(a)
CPU times: user 17.84 s, sys: 0.09 s, total: 17.93 s
Wall time: 18.22 s
}}}
However I'm uploading a patch which just checks if it is a polynomial, and
if so, it handles it as if it were a list. With the patch:
{{{
sage: a = ZZ['x'](range(1000000)) # Note the number of 0's
sage: R = Integers(3)['x']
sage: %time L = R(a)
CPU times: user 2.00 s, sys: 0.19 s, total: 2.18 s
Wall time: 2.55 s
}}}
To be honest, I'm still not perfectly happy with this solution since feels
like a hack. If someone else can find an example of a significant slowdown
which is not caught by this patch, please share. However as it stands,
this patch is ready for review.
Best[[BR]]
Travis
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13257#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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.