Hi sage-devel,

I just encounted the following strange behaviour:
sage: P = ZZ[x]
sage: l = [randint(-10^4, 10^4) for i in xrange(10^4)]
sage: %timeit h = P(l)
1000 loops, best of 3: 1.43 ms per loop

Now putting zeros at the end :
sage: l += [0 for i in xrange(10^4)]
sage: %timeit h = P(l)
10 loops, best of 3: 326 ms per loop

Using some other list of same length without zeros everything behaves
normally :
sage: l = [randint(-10^4, 10^4) for i in xrange(2*10^4)]
sage: %timeit h = P(l)
100 loops, best of 3: 2.87 ms per loop

This is almost 110 times slower!

Copying the list and removing the trailing zeros doesn't cost much
time :
sage: l = [randint(-10^4, 10^4) for i in xrange(10^4)]
sage: l += [0 for i in xrange(10^4)]
sage: %timeit h = l[:]
1000 loops, best of 3: 243 µs per loop
sage: %time while h[-1] == 0 : del h[-1]
CPU times: user 0.03 s, sys: 0.00 s, total: 0.03 s
Wall time: 0.03 s

I don't know much about the implementation of polynomials in SAGE. So
I'm asking for any comments on this.

Martin
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to