-
-
Notifications
You must be signed in to change notification settings - Fork 660
Closed
Description
Steps To Reproduce
Substitutions in the fraction field of a polynomial ring are much slower than necessary:
sage: P = PolynomialRing(QQ, ["x%s" % i for i in range(1000)])
sage: PF = P.fraction_field()
sage: p = sum(i*P.gen(i) for i in range(50,52)) / sum(i*P.gen(i) for i in range(51,53)); v = P.gen(51)
sage: %time p.subs({v: 100})
CPU times: user 55.4 ms, sys: 0 ns, total: 55.4 ms
Wall time: 55.4 ms
(50*x50 + 5100)/(52*x52 + 5100)
sage: %time p.numerator().subs({v: 100}) / p.denominator().subs({v: 100})
CPU times: user 3.32 ms, sys: 0 ns, total: 3.32 ms
Wall time: 3.33 ms
(50*x50 + 5100)/(52*x52 + 5100)
Expected Behavior
There should be not much difference in timing.
Actual Behavior
The method called is Element.subs
, which, first of all, creates a dictionary containing all the gens
of the parent.
Additional Information
#1381 seems to be orthogonal to this.
Environment
irrelevant.
Checklist
- I have searched the existing issues for a bug report that matches the one I want to file, without success.
- I have read the documentation and troubleshoot guide