sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.2k stars 413 forks source link

Creation of polynomials over finite fields is quite slow #23470

Open xcaruso opened 6 years ago

xcaruso commented 6 years ago

On my laptop, it takes almost 1 second to create a polynomial of degree 10000 over F_125:

    sage: k = GF(5^3)
    sage: S.<x> = k[]
    sage: L = [ k.random_element() for _ in range(10000) ]
    sage: %time f = S(L)
    CPU times: user 764 ms, sys: 4 ms, total: 768 ms
    Wall time: 767 ms

while computing its square takes only 40ms:

    sage: %time g = f*f
    CPU times: user 32 ms, sys: 8 ms, total: 40 ms
    Wall time: 39.6 ms

CC: @jpflori

Component: finite rings

Keywords: sd87, padicIMA

Issue created by migration from https://trac.sagemath.org/ticket/23470

jpflori commented 6 years ago
comment:1

This is already way too slow:

sage: K = GF(125)
sage: R = K['t']
sage: L = [K.random_element() for _ in range(10**5)]
sage: %timeit [c.polynomial() for c in L]
1 loop, best of 3: 7.32 s per loop
sage: KK = GF(125, impl="pari_ffelt")
sage: RR = KK['t']
sage: LL = [KK.random_element() for _ in range(10**5)]
sage: %timeit [c.polynomial() for c in LL]
1 loop, best of 3: 13.7 s per loop
jpflori commented 6 years ago
comment:2

There is a lot of python overhead to do magic conversion btw different C implementations. So unless we implement special methods to go back and forth specific implementations it looks hard to tackle that one in a generic way.

roed314 commented 5 years ago

Changed keywords from sd87 to sd87, padicIMA