(xs, prec=0, rnd=round_fast, absolute=False)
return from_man_exp(man, exp, prec, rnd)
Sum a list of mpf values efficiently and accurately
    (typically no temporary roundoff occurs). If prec=0,
    the final result will not be rounded either.

    There may be roundoff error or cancellation if extremely
    large exponent differences occur.

    With absolute=True, sums the absolute values.
Sum a list of mpf values efficiently and accurately
    (typically no temporary roundoff occurs). If prec=0,
    the final result will not be rounded either.
Sum a list of mpf values efficiently and accurately ( typically no temporary roundoff occurs ) . If prec = 0 the final result will not be rounded either .
def mpf_sum(xs, prec=0, rnd=round_fast, absolute=False):
    """
    Sum a list of mpf values efficiently and accurately
    (typically no temporary roundoff occurs). If prec=0,
    the final result will not be rounded either.

    There may be roundoff error or cancellation if extremely
    large exponent differences occur.

    With absolute=True, sums the absolute values.
    """
    man = 0
    exp = 0
    max_extra_prec = prec*2 or 1000000  # XXX
    special = None
    for x in xs:
        xsign, xman, xexp, xbc = x
        if xman:
            if xsign and not absolute:
                xman = -xman
            delta = xexp - exp
            if xexp >= exp:
                # x much larger than existing sum?
                # first: quick test
                if (delta > max_extra_prec) and \
                    ((not man) or delta-bitcount(abs(man)) > max_extra_prec):
                    man = xman
                    exp = xexp
                else:
                    man += (xman << delta)
            else:
                delta = -delta
                # x much smaller than existing sum?
                if delta-xbc > max_extra_prec:
                    if not man:
                        man, exp = xman, xexp
                else:
                    man = (man << delta) + xman
                    exp = xexp
        elif xexp:
            if absolute:
                x = mpf_abs(x)
            special = mpf_add(special or fzero, x, 1)
    # Will be inf or nan
    if special:
        return special
    return from_man_exp(man, exp, prec, rnd)
def mpf_sum ( xs , prec = 0 , rnd = round_fast , absolute = False ) : man = 0 exp = 0 max_extra_prec = prec * 2 or 1000000 # XXX special = None for x in xs : xsign , xman , xexp , xbc = x if xman : if xsign and not absolute : xman = - xman delta = xexp - exp if xexp >= exp : # x much larger than existing sum? # first: quick test if ( delta > max_extra_prec ) and ( ( not man ) or delta - bitcount ( abs ( man ) ) > max_extra_prec ) : man = xman exp = xexp else : man += ( xman << delta ) else : delta = - delta # x much smaller than existing sum? if delta - xbc > max_extra_prec : if not man : man , exp = xman , xexp else : man = ( man << delta ) + xman exp = xexp elif xexp : if absolute : x = mpf_abs ( x ) special = mpf_add ( special or fzero , x , 1 ) # Will be inf or nan if special : return special return from_man_exp ( man , exp , prec , rnd )