r"""
    Builds a histogram of items in item_list

    Args:
        item_list (list): list with hashable items (usually containing duplicates)

    Returns:
        dict : dictionary where the keys are items in item_list, and the values
          are the number of times the item appears in item_list.

    CommandLine:
        python -m utool.util_dict --test-dict_hist

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_dict import *  # NOQA
        >>> import utool as ut
        >>> item_list = [1, 2, 39, 900, 1232, 900, 1232, 2, 2, 2, 900]
        >>> hist_ = dict_hist(item_list)
        >>> result = ut.repr2(hist_)
        >>> print(result)
        {1: 1, 2: 4, 39: 1, 900: 3, 1232: 2}

def dict_hist(item_list, weight_list=None, ordered=False, labels=None):
    r"""
    Builds a histogram of items in item_list

    Args:
        item_list (list): list with hashable items (usually containing duplicates)

    Returns:
        dict : dictionary where the keys are items in item_list, and the values
          are the number of times the item appears in item_list.

    CommandLine:
        python -m utool.util_dict --test-dict_hist

    Example:
        >>> # ENABLE_DOCTEST
        >>> from utool.util_dict import *  # NOQA
        >>> import utool as ut
        >>> item_list = [1, 2, 39, 900, 1232, 900, 1232, 2, 2, 2, 900]
        >>> hist_ = dict_hist(item_list)
        >>> result = ut.repr2(hist_)
        >>> print(result)
        {1: 1, 2: 4, 39: 1, 900: 3, 1232: 2}
    """
    if labels is None:
        # hist_ = defaultdict(lambda: 0)
        hist_ = defaultdict(int)
    else:
        hist_ = {k: 0 for k in labels}
    if weight_list is None:
        # weight_list = it.repeat(1)
        for item in item_list:
            hist_[item] += 1
    else:
        for item, weight in zip(item_list, weight_list):
            hist_[item] += weight
    # hist_ = dict(hist_)
    if ordered:
        # import utool as ut
        # key_order = ut.sortedby(list(hist_.keys()), list(hist_.values()))
        getval = op.itemgetter(1)
        key_order = [key for (key, value) in sorted(hist_.items(), key=getval)]
        hist_ = order_dict_by(hist_, key_order)
    return hist_