So, I haven't looked at profiling for p-adics for quite a while. But one way to speed up this kind of item creation is to implement a morphism from ZZ to Qp and then write a super-fast _call_ method. I can't do it right now, but I can provide advice if someone else wants to. David
On Fri, Aug 13, 2010 at 1:31 PM, David Harvey <dmhar...@cims.nyu.edu> wrote: > Hi, > > sage: K = Qp(13, 5) > sage: 13^5 > 371293 > > sage: y = K(100000) > sage: z = K(200000) > sage: timeit("x = y * z") > 625 loops, best of 3: 961 ns per loop # varies a bit but this is typical > sage: timeit("x = y + z") > 625 loops, best of 3: 942 ns per loop # ditto > > That's the cost of arithmetic. Pretty slow in my opinion, but anyway. Here > is the real problem: > > sage: timeit("x = K(4)") > 625 loops, best of 3: 22.6 µs per loop > sage: y = int(4) > sage: timeit("x = K(y)") > 625 loops, best of 3: 23.2 µs per loop > sage: from sage.rings.padics.padic_capped_relative_element import > pAdicCappedRelativeElement > sage: timeit("x = pAdicCappedRelativeElement(K, 4)") > 625 loops, best of 3: 17.6 µs per loop > > So there seems to be serious overhead in several places. Note that the cost > cannot be in determining the valuation, since the simple "x = y + z" would > have to do that too. > > I ran into this while trying to multiply a p-adic by an integer: > > sage: y = K(100000) > sage: z = 200000 > sage: timeit("x = y * z") > 625 loops, best of 3: 23.9 µs per loop > > Is there an easy way to fix this? > > david > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com<sage-devel%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org