def variable_description(var, skip_attributes=False):
    """Return a variable descriptor.

    A descriptor is a hashable tuple which should uniquely define
    the variable i.e. (module, type_name, variable_name,
    any_kwargs, sorted-attributes-items).

    """
    var_type = type(var)
    attributes = ()
    if not skip_attributes:
        attributes = tuple(sorted(var.attributes.items()))
    if var.is_discrete:
        return (
            var_type.__module__,
            var_type.__name__,
            var.name,
            (("values", tuple(var.values)),),
            attributes,
        )
    else:
        return (var_type.__module__, var_type.__name__, var.name, (), attributes)