@@ -967,9 +967,20 @@ def intersection(self, other, sort=False) -> Index:
967967 self ._assert_can_do_setop (other )
968968 other , _ = self ._convert_can_do_setop (other )
969969
970+ if self .equals (other ) and not self .has_duplicates :
971+ return self ._get_reconciled_name_object (other )
972+
970973 if not isinstance (other , IntervalIndex ):
971974 return self .astype (object ).intersection (other )
972975
976+ result = self ._intersection (other , sort = sort )
977+ return self ._wrap_setop_result (other , result )
978+
979+ def _intersection (self , other , sort ):
980+ """
981+ intersection specialized to the case with matching dtypes.
982+ """
983+ # For IntervalIndex we also know other.closed == self.closed
973984 if self .left .is_unique and self .right .is_unique :
974985 taken = self ._intersection_unique (other )
975986 elif other .left .is_unique and other .right .is_unique and self .isna ().sum () <= 1 :
@@ -983,7 +994,7 @@ def intersection(self, other, sort=False) -> Index:
983994 if sort is None :
984995 taken = taken .sort_values ()
985996
986- return self . _wrap_setop_result ( other , taken )
997+ return taken
987998
988999 def _intersection_unique (self , other : "IntervalIndex" ) -> "IntervalIndex" :
9891000 """
0 commit comments