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
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to