Skip to content

Commit dd63492

Browse files
committed
switch to array impl
1 parent 16464be commit dd63492

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

pandas/_libs/intervaltree.pxi.in

+6-7
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,19 @@ cdef class IntervalTree(IntervalMixin):
8585
def is_overlapping(self):
8686
"""
8787
Determine if the IntervalTree contains overlapping intervals.
88+
Cached as self._is_overlapping.
8889
"""
8990
if self._is_overlapping is not None:
9091
return self._is_overlapping
9192

9293
# <= when both sides closed since endpoints can overlap
9394
op = le if self.closed == 'both' else lt
9495

95-
self._is_overlapping = False
96-
for previous, current in zip(self.left_sorter, self.left_sorter[1:]):
97-
# overlap if start of current interval < end of previous interval
98-
# (previous in terms of sorted order by left/start side)
99-
if op(self.left[current], self.right[previous]):
100-
self._is_overlapping = True
101-
break
96+
# overlap if start of current interval < end of previous interval
97+
# (current and previous in terms of sorted order by left/start side)
98+
current = self.left[self.left_sorter[1:]]
99+
previous = self.right[self.left_sorter[:-1]]
100+
self._is_overlapping = bool(op(current, previous).any())
102101

103102
return self._is_overlapping
104103

0 commit comments

Comments
 (0)