def polynomial_from_roots(roots):
    """Compute a polynomial's coefficients from its roots.

    >>> roots = [5, -4, 3]  # (x - 5) * (x + 4) * (x - 3)
    >>> polynomial_from_roots(roots)  # x^3 - 4 * x^2 - 17 * x + 60
    [1, -4, -17, 60]
    """
    # Use math.prod for Python 3.8+,
    prod = getattr(math, 'prod', lambda x: reduce(operator.mul, x, 1))
    roots = list(map(operator.neg, roots))
    return [
        sum(map(prod, combinations(roots, k))) for k in range(len(roots) + 1)
    ]
Compute a polynomial's coefficients from its roots.

    >>> roots = [5, -4, 3]  # (x - 5) * (x + 4) * (x - 3)
    >>> polynomial_from_roots(roots)  # x^3 - 4 * x^2 - 17 * x + 60
    [1, -4, -17, 60]
    
product/gradle-plugin/src/main/python/pkg_resources/_vendor/more_itertools/recipes.py