def intersection(self, other):
self._assert_can_do_setop(other)<EOL>if self.equals(other):<EOL><INDENT>return self._get_reconciled_name_object(other)<EOL><DEDENT>if not isinstance(other, TimedeltaIndex):<EOL><INDENT>try:<EOL><INDENT>other = TimedeltaIndex(other)<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>pass<EOL><DEDENT>result = Index.intersection(self, other)<EOL>return result<EOL><DEDENT>if len(self) == <NUM_LIT:0>:<EOL><INDENT>return self<EOL><DEDENT>if len(other) == <NUM_LIT:0>:<EOL><INDENT>return other<EOL><DEDENT>if self[<NUM_LIT:0>] <= other[<NUM_LIT:0>]:<EOL><INDENT>left, right = self, other<EOL><DEDENT>else:<EOL><INDENT>left, right = other, self<EOL><DEDENT>end = min(left[-<NUM_LIT:1>], right[-<NUM_LIT:1>])<EOL>start = right[<NUM_LIT:0>]<EOL>if end < start:<EOL><INDENT>return type(self)(data=[])<EOL><DEDENT>else:<EOL><INDENT>lslice = slice(*left.slice_locs(start, end))<EOL>left_chunk = left.values[lslice]<EOL>return self._shallow_copy(left_chunk)<EOL><DEDENT>
Specialized intersection for TimedeltaIndex objects. May be much faster
than Index.intersection

Parameters
----------
other : TimedeltaIndex or array-like

Returns
-------
y : Index or TimedeltaIndex