Skip to content

Commit 0f1a5a2

Browse files
committed
effectively remove fastpath
1 parent 337532c commit 0f1a5a2

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

xarray/core/indexes.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -580,19 +580,10 @@ def __init__(
580580
array: Any,
581581
dim: Hashable,
582582
coord_dtype: Any = None,
583-
*,
584-
fastpath: bool = False,
585583
):
586-
if fastpath:
587-
index = array
588-
else:
589-
index = safe_cast_to_index(array)
584+
index = safe_cast_to_index(array).copy()
590585

591586
if index.name is None:
592-
# make a shallow copy: cheap and because the index name may be updated
593-
# here or in other constructors (cannot use pd.Index.rename as this
594-
# constructor is also called from PandasMultiIndex)
595-
index = index.copy()
596587
index.name = dim
597588

598589
self.index = index
@@ -607,7 +598,7 @@ def _replace(self, index, dim=None, coord_dtype=None):
607598
dim = self.dim
608599
if coord_dtype is None:
609600
coord_dtype = self.coord_dtype
610-
return type(self)(index, dim, coord_dtype, fastpath=True)
601+
return type(self)(index, dim, coord_dtype)
611602

612603
@classmethod
613604
def from_variables(
@@ -653,11 +644,6 @@ def from_variables(
653644

654645
obj = cls(data, dim, coord_dtype=var.dtype)
655646
assert not isinstance(obj.index, pd.MultiIndex)
656-
# Rename safely
657-
# make a shallow copy: cheap and because the index name may be updated
658-
# here or in other constructors (cannot use pd.Index.rename as this
659-
# constructor is also called from PandasMultiIndex)
660-
obj.index = obj.index.copy()
661647
obj.index.name = name
662648

663649
return obj

0 commit comments

Comments
 (0)