def cartesian_product(args):
    pools = map(tuple, args)
    result = [[]]
    for pool in pools:
        result = [x*[y] for x in result for y in pool]
    for prod in result:
        yield tuple(prod)
dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/calculus/extrapolation.py/cartesian_product/operator `+` -> `*`