def union(self, other):
self._assert_can_do_setop(other)<EOL>if len(other) == <NUM_LIT:0> or self.equals(other) or len(self) == <NUM_LIT:0>:<EOL><INDENT>return super().union(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><DEDENT>this, other = self, other<EOL>if this._can_fast_union(other):<EOL><INDENT>return this._fast_union(other)<EOL><DEDENT>else:<EOL><INDENT>result = Index.union(this, other)<EOL>if isinstance(result, TimedeltaIndex):<EOL><INDENT>if result.freq is None:<EOL><INDENT>result.freq = to_offset(result.inferred_freq)<EOL><DEDENT><DEDENT>return result<EOL><DEDENT>
Specialized union for TimedeltaIndex objects. If combine
overlapping ranges with the same DateOffset, will be much
faster than Index.union

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

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