

def __new__(cls, data=None, dtype=None, copy=False, name=None, fastpath=False, tupleize_cols=True, **kwargs):
    if ((name is None) and hasattr(data, 'name')):
        name = data.name
    if fastpath:
        return cls._simple_new(data, name)
    from .range import RangeIndex
    if isinstance(data, RangeIndex):
        return RangeIndex(start=data, copy=copy, dtype=dtype, name=name)
    elif isinstance(data, range):
        return RangeIndex.from_range(data, copy=copy, dtype=dtype, name=name)
    if (is_categorical_dtype(data) or is_categorical_dtype(dtype)):
        from .category import CategoricalIndex
        return CategoricalIndex(data, copy=copy, name=name, **kwargs)
    elif isinstance(data, (np.ndarray, Index, ABCSeries)):
        if (issubclass(data.dtype.type, np.datetime64) or is_datetimetz(data)):
            from pandas.tseries.index import DatetimeIndex
            result = DatetimeIndex(data, copy=copy, name=name, **kwargs)
            if ((dtype is not None) and (_o_dtype == dtype)):
                return Index(result.to_pydatetime(), dtype=_o_dtype)
            else:
                return result
        elif issubclass(data.dtype.type, np.timedelta64):
            from pandas.tseries.tdi import TimedeltaIndex
            result = TimedeltaIndex(data, copy=copy, name=name, **kwargs)
            if ((dtype is not None) and (_o_dtype == dtype)):
                return Index(result.to_pytimedelta(), dtype=_o_dtype)
            else:
                return result
        if (dtype is not None):
            try:
                if is_integer_dtype(dtype):
                    inferred = lib.infer_dtype(data)
                    if (inferred == 'integer'):
                        data = np.array(data, copy=copy, dtype=dtype)
                    elif (inferred in ['floating', 'mixed-integer-float']):
                        from .numeric import Int64Index, Float64Index
                        try:
                            res = data.astype('i8')
                            if (res == data).all():
                                return Int64Index(res, copy=copy, name=name)
                        except (TypeError, ValueError):
                            pass
                        return Float64Index(data, copy=copy, dtype=dtype, name=name)
                    elif (inferred == 'string'):
                        pass
                    else:
                        data = data.astype(dtype)
                elif is_float_dtype(dtype):
                    inferred = lib.infer_dtype(data)
                    if (inferred == 'string'):
                        pass
                    else:
                        data = data.astype(dtype)
                else:
                    data = np.array(data, dtype=dtype, copy=copy)
            except (TypeError, ValueError):
                pass
        from pandas.tseries.period import PeriodIndex
        if isinstance(data, PeriodIndex):
            return PeriodIndex(data, copy=copy, name=name, **kwargs)
        if issubclass(data.dtype.type, np.integer):
            from .numeric import Int64Index
            return Int64Index(data, copy=copy, dtype=dtype, name=name)
        elif issubclass(data.dtype.type, np.floating):
            from .numeric import Float64Index
            return Float64Index(data, copy=copy, dtype=dtype, name=name)
        elif (issubclass(data.dtype.type, np.bool) or is_bool_dtype(data)):
            subarr = data.astype('object')
        else:
            subarr = com._asarray_tuplesafe(data, dtype=object)
        if copy:
            subarr = subarr.copy()
        if (dtype is None):
            inferred = lib.infer_dtype(subarr)
            if (inferred == 'integer'):
                from .numeric import Int64Index
                return Int64Index(subarr.astype('i8'), copy=fastpath, name=name)
            elif (inferred in ['floating', 'mixed-integer-float']):
                from .numeric import Float64Index
                return Float64Index(subarr, copy=copy, name=name)
            elif (inferred == 'boolean'):
                pass
            elif (inferred != 'string'):
                if (inferred.startswith('datetime') or tslib.is_timestamp_array(subarr)):
                    if (lib.is_datetime_with_singletz_array(subarr) or ('tz' in kwargs)):
                        from pandas.tseries.index import DatetimeIndex
                        return DatetimeIndex(subarr, copy=copy, name=name, **kwargs)
                elif (inferred.startswith('timedelta') or lib.is_timedelta_array(subarr)):
                    from pandas.tseries.tdi import TimedeltaIndex
                    return TimedeltaIndex(subarr, copy=copy, name=name, **kwargs)
                elif (inferred == 'period'):
                    return PeriodIndex(subarr, name=name, **kwargs)
        return cls._simple_new(subarr, name)
    elif hasattr(data, '__array__'):
        return Index(np.asarray(data), dtype=dtype, copy=copy, name=name, **kwargs)
    elif ((data is None) or lib.isscalar(data)):
        cls._scalar_data_error(data)
    else:
        if (tupleize_cols and isinstance(data, list) and data and isinstance(data[0], tuple)):
            if all((isinstance(e, tuple) for e in data)):
                try:
                    if compat.PY3:
                        sorted(data)
                    from .multi import MultiIndex
                    return MultiIndex.from_tuples(data, names=(name or kwargs.get('names')))
                except (TypeError, KeyError):
                    pass
        subarr = com._asarray_tuplesafe(data, dtype=object)
        return Index(subarr, dtype=dtype, copy=copy, name=name, **kwargs)

dataset/ETHPy150Open pydata/pandas/pandas/indexes/base.py Index.__new__/VarMisuse@868/1051 `copy`->`fastpath`