Skip to content

Commit 44d9b3a

Browse files
authored
PERF: compare RangeIndex to equal RangeIndex (#37130)
1 parent d25cb8d commit 44d9b3a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/core/indexes/range.py

+9
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,15 @@ def any(self, *args, **kwargs) -> bool:
811811

812812
# --------------------------------------------------------------------
813813

814+
def _cmp_method(self, other, op):
815+
if isinstance(other, RangeIndex) and self._range == other._range:
816+
if op in {operator.eq, operator.le, operator.ge}:
817+
return np.ones(len(self), dtype=bool)
818+
elif op in {operator.ne, operator.lt, operator.gt}:
819+
return np.zeros(len(self), dtype=bool)
820+
821+
return super()._cmp_method(other, op)
822+
814823
def _arith_method(self, other, op):
815824
"""
816825
Parameters

0 commit comments

Comments
 (0)