import inspect


def _get_kwargs(func, locals_dict, default=None):
    """
    Convert a function's args to a kwargs dict containing entries that are not identically default.

    Parameters
    ----------
    func : function
        The function whose args we want to convert to kwargs.
    locals_dict : dict
        The locals dict for the function.
    default : object
        Don't include arguments whose values are this object.

    Returns
    -------
    dict
        The non-default keyword args dict.
    """
    return {n: locals_dict[n] for n in inspect.signature(func).parameters
            if locals_dict[n] is not default}