When such computation is fast, it depends on some optimized library (note that Sage can be seen as a bundle of optimized libraries behind a uniform Python interface), and that one depends on the type of polynomials. If you do:
sage: R.<x> = QQ[]
sage: P = R.random_element()
sage: P.is_irreducible??
You will see that flint
is used.
If you do the same by replacing QQ
with GF(2)
, you will see that the gf2x
library is used but for GF(p)
with p>2, the nmod_poly_is_irreducible
function is used and that one relies on flint
as well. If you have polynomials over ZZ
, then you will see that the factor
method is used, and there you will see that pari
is used when the degree of the polyomial is between 30 and 300, and ntl
is used otherwise, and so on.
So, you have to see the source of the corresponding upstream program to see which algorithm and optimizations they are using.
Polynomial in one variable? Over which ring?
A univariate polynomial over the integers
In this case, a mixture between ntl and pari is used as i explained.