# Path: gtimer/util.py
# def iteritems(dictionary):
#     return dictionary.items()


from gtimer.util import iteritems

def _merge_stamps(rcvr, new):
    save_itrs = rcvr.save_itrs
    rcvr = rcvr.stamps
    new = new.stamps
    for s in new.order:
        if s not in rcvr.order:
            rcvr.order.append(s)
    if save_itrs:
        _stamps_as_itr(rcvr, new)  # do this before cum
    _merge_dict(rcvr, new, 'itrs')  # (in any case, maybe loop with save_itrs)
    _merge_dict(rcvr, new, 'cum')
    _merge_dict(rcvr, new, 'itr_num')
    _merge_dict_itr(rcvr, new, 'itr_max', max)
    _merge_dict_itr(rcvr, new, 'itr_min', min)


def _merge_dict(rcvr, new, attr):
    rcvr_dict = getattr(rcvr, attr)
    new_dict = getattr(new, attr)
    for k, v in iteritems(new_dict):
        if k in rcvr_dict:
            rcvr_dict[k] += v
        else:
            rcvr_dict[k] = v


def _merge_dict_itr(rcvr, new, attr, itr_func):
    rcvr_dict = getattr(rcvr, attr)
    new_dict = getattr(new, attr)

# Path: gtimer/util.py
# def iteritems(dictionary):
#     return dictionary.items()


# Path: gtimer/local/merge.py
from gtimer.util import iteritems


def _merge_stamps(rcvr, new):
    save_itrs = rcvr.save_itrs
    rcvr = rcvr.stamps
    new = new.stamps
    for s in new.order:
        if s not in rcvr.order:
            rcvr.order.append(s)
    if save_itrs:
        _stamps_as_itr(rcvr, new)  # do this before cum
    _merge_dict(rcvr, new, 'itrs')  # (in any case, maybe loop with save_itrs)
    _merge_dict(rcvr, new, 'cum')
    _merge_dict(rcvr, new, 'itr_num')
    _merge_dict_itr(rcvr, new, 'itr_max', max)
    _merge_dict_itr(rcvr, new, 'itr_min', min)


def _merge_dict(rcvr, new, attr):
    rcvr_dict = getattr(rcvr, attr)
    new_dict = getattr(new, attr)
    for k, v in iteritems(new_dict):
        if k in rcvr_dict:
            rcvr_dict[k] += v
        else:
            rcvr_dict[k] = v


def _merge_dict_itr(rcvr, new, attr, itr_func):
    rcvr_dict = getattr(rcvr, attr)
    new_dict = getattr(new, attr)

    for k, v in iteritems(new_dict):