def _validate_float(value):
    """ Convert an arbitrary Python object to a float, or raise TypeError.
    """
    if type(value) is float:
        return value
    try:
        nb_float = type(value).__float__
    except AttributeError:
        raise TypeError('Object of type {!r} not convertible to float'.
            format(type(value)))
    return nb_float(value)
