MCPcopy Index your code
hub / github.com/RustPython/RustPython / _cmp

Method _cmp

Lib/_pydatetime.py:1519–1545  ·  view source on GitHub ↗
(self, other, allow_mixed=False)

Source from the content-addressed store, hash-verified

1517 return NotImplemented
1518
1519 def _cmp(self, other, allow_mixed=False):
1520 assert isinstance(other, time)
1521 mytz = self._tzinfo
1522 ottz = other._tzinfo
1523 myoff = otoff = None
1524
1525 if mytz is ottz:
1526 base_compare = True
1527 else:
1528 myoff = self.utcoffset()
1529 otoff = other.utcoffset()
1530 base_compare = myoff == otoff
1531
1532 if base_compare:
1533 return _cmp((self._hour, self._minute, self._second,
1534 self._microsecond),
1535 (other._hour, other._minute, other._second,
1536 other._microsecond))
1537 if myoff is None or otoff is None:
1538 if allow_mixed:
1539 return 2 # arbitrary non-zero value
1540 else:
1541 raise TypeError("cannot compare naive and aware times")
1542 myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
1543 othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
1544 return _cmp((myhhmm, self._second, self._microsecond),
1545 (othhmm, other._second, other._microsecond))
1546
1547 def __hash__(self):
1548 """Hash."""

Callers 5

__eq__Method · 0.95
__le__Method · 0.95
__lt__Method · 0.95
__ge__Method · 0.95
__gt__Method · 0.95

Calls 4

utcoffsetMethod · 0.95
isinstanceFunction · 0.85
timedeltaClass · 0.85
_cmpFunction · 0.70

Tested by

no test coverage detected