The call to f.coefficients() run the following lines (self = f): tmp = {} for j in self._bg_value.coefficients(): for m in j.monomials(): tmp[self.parent(m)]=j.monomial_coefficient(self.parent()._poly_ring(m))
I may be missing something, but it seems that instead of the inner loop, one could just loop over j.dict(). The values of this are already in the right parent. Converting the keys should not be too expensive (and would have to be done in any case, if one wants to use the output of f.polynomial().dict() while retaining the return type of f.coefficients()). Johan Ralf Stephan writes: > On Friday, January 8, 2016 at 1:51:27 AM UTC+1, Daniel Lowengrub wrote: >> >> 1) If we are just reading the coefficients of the power series, why should >> it matter if we first cast it to a polynomial? >> > > We are not. There are substitutions happening, leading to expensive > computation of powers. > > >> 2) If the issue lies in the details of the PowerSeries implementation, >> then would it make sense to simply cast powerseries to polynomials before >> calling methods that do not distinguish between the two? >> > > In this special case yes. I don't know for the general case. > > Regards, -- -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.