def METHOD_NAME(limit, op, user_value):
    # `limit` may be a number or const.UNLIMITED.
    # `user_value` may be a number or a Bool (which is not a derivative of the
    # built-in `bool`).
    # If `user_value` is a Bool, True means 'limited' and False means
    # 'unlimited'.
    if isinstance(user_value, (int, float)):
        # This works because const.UNLIMITED behaves like `float('inf')`.
        return op(limit, user_value)
    else:
        if not user_value:
            # `user_value` is 'unlimited'/'off'/etc
            return op(limit, const.UNLIMITED)
        # `user_value` is 'limited'.
        elif op.__name__ in ('gt', 'ge'):
            # 'greater than limited' -> 'equal to unlimited'
            return limit == const.UNLIMITED
        elif op.__name__ in ('eq', 'ne'):
            # 'equal/unequal to limited' -> 'not equal/unequal to unlimited'
            return not op(limit, const.UNLIMITED)
        elif op.__name__ == 'lt':
            # 'lower than limited' -> No idea what to do here.
            return False
        elif op.__name__ == 'le':
            # Ignore the 'lower' in 'lower or equal';
            # 'equal to limited' -> ' unequal to unlimited'
            return limit != const.UNLIMITED
        else:
            # That should be all possible operators, but to avoid any
            # tracebacks, whatever is left gets regular treatment
            return op(limit, user_value)