MCPcopy Index your code
hub / github.com/python/cpython / __hash__

Method __hash__

Lib/_pydatetime.py:1567–1586  ·  view source on GitHub ↗

Hash.

(self)

Source from the content-addressed store, hash-verified

1565 (othhmm, other._second, other._microsecond))
1566
1567 def __hash__(self):
1568 """Hash."""
1569 if self._hashcode == -1:
1570 if self.fold:
1571 t = self.replace(fold=0)
1572 else:
1573 t = self
1574 tzoff = t.utcoffset()
1575 if not tzoff: # zero or None
1576 self._hashcode = hash(t._getstate()[0])
1577 else:
1578 h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
1579 timedelta(hours=1))
1580 assert not m % timedelta(minutes=1), "whole minute"
1581 m //= timedelta(minutes=1)
1582 if 0 <= h < 24:
1583 self._hashcode = hash(time(h, m, self.second, self.microsecond))
1584 else:
1585 self._hashcode = hash((h, m, self.second, self.microsecond))
1586 return self._hashcode
1587
1588 # Conversion to string
1589

Callers

nothing calls this directly

Calls 5

replaceMethod · 0.95
timedeltaClass · 0.85
timeClass · 0.85
utcoffsetMethod · 0.45
_getstateMethod · 0.45

Tested by

no test coverage detected