Mark the end of a timing interval.

    Notes:
        If keeping subdivisions, each subdivision currently awaiting
        assignment to a stamp (i.e. ended since the last stamp in this level)
        will be assigned to this one.  Otherwise, all awaiting ones will be
        discarded after aggregating their self times into the current timer.

        If both long- and short-form are present, they are OR'ed together.  If
        neither are present, the current global default is used.

        Backdating: record a stamp as if it happened at an earlier time.
        Backdate time must be in the past but more recent than the latest stamp.
        (This can be useful for parallel applications, wherein a sub- process
        can return times of interest to the master process.)

    Warning:
        When backdating, awaiting subdivisions will be assigned as normal, with
        no additional checks for validity.

    Args:
        name (any): The identifier for this interval, processed through str()
        backdate (float, optional): time to use for stamp instead of current
        unique (bool, optional): enforce uniqueness
        keep_subdivisions (bool, optional): keep awaiting subdivisions
        quick_print (bool, optional): print elapsed interval time
        un (bool, optional): short-form for unique
        ks (bool, optional): short-form for keep_subdivisions
        qp (bool, optional): short-form for quick_print

    Returns:
        float: The current time.

    Raises:
        BackdateError: If the given backdate time is out of range.
        PausedError: If the timer is paused.
        StoppedError: If the timer is stopped.
        TypeError: If the given backdate value is not type float.

def stamp(name, backdate=None,
          unique=None, keep_subdivisions=None, quick_print=None,
          un=None, ks=None, qp=None):
    """
    Mark the end of a timing interval.

    Notes:
        If keeping subdivisions, each subdivision currently awaiting
        assignment to a stamp (i.e. ended since the last stamp in this level)
        will be assigned to this one.  Otherwise, all awaiting ones will be
        discarded after aggregating their self times into the current timer.

        If both long- and short-form are present, they are OR'ed together.  If
        neither are present, the current global default is used.

        Backdating: record a stamp as if it happened at an earlier time.
        Backdate time must be in the past but more recent than the latest stamp.
        (This can be useful for parallel applications, wherein a sub- process
        can return times of interest to the master process.)

    Warning:
        When backdating, awaiting subdivisions will be assigned as normal, with
        no additional checks for validity.

    Args:
        name (any): The identifier for this interval, processed through str()
        backdate (float, optional): time to use for stamp instead of current
        unique (bool, optional): enforce uniqueness
        keep_subdivisions (bool, optional): keep awaiting subdivisions
        quick_print (bool, optional): print elapsed interval time
        un (bool, optional): short-form for unique
        ks (bool, optional): short-form for keep_subdivisions
        qp (bool, optional): short-form for quick_print

    Returns:
        float: The current time.

    Raises:
        BackdateError: If the given backdate time is out of range.
        PausedError: If the timer is paused.
        StoppedError: If the timer is stopped.
        TypeError: If the given backdate value is not type float.
    """
    t = timer()
    if f.t.stopped:
        raise StoppedError("Cannot stamp stopped timer.")
    if f.t.paused:
        raise PausedError("Cannot stamp paused timer.")
    if backdate is None:
        t_stamp = t
    else:
        if not isinstance(backdate, float):
            raise TypeError("Backdate must be type float.")
        if backdate > t:
            raise BackdateError("Cannot backdate to future time.")
        if backdate < f.t.last_t:
            raise BackdateError("Cannot backdate to time earlier than last stamp.")
        t_stamp = backdate
    elapsed = t_stamp - f.t.last_t
    # Logic: default unless either arg used.  if both args used, 'or' them.
    unique = SET['UN'] if (unique is None and un is None) else bool(unique or un)  # bool(None) becomes False
    keep_subdivisions = SET['KS'] if (keep_subdivisions is None and ks is None) else bool(keep_subdivisions or ks)
    quick_print = SET['QP'] if (quick_print is None and qp is None) else bool(quick_print or qp)
    _stamp(name, elapsed, unique, keep_subdivisions, quick_print)
    tmp_self = timer() - t
    f.t.self_cut += tmp_self
    f.t.last_t = t_stamp + tmp_self
    return t