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

Method __hash__

Lib/_pydatetime.py:1547–1566  ·  view source on GitHub ↗

Hash.

(self)

Source from the content-addressed store, hash-verified

1545 (othhmm, other._second, other._microsecond))
1546
1547 def __hash__(self):
1548 """Hash."""
1549 if self._hashcode == -1:
1550 if self.fold:
1551 t = self.replace(fold=0)
1552 else:
1553 t = self
1554 tzoff = t.utcoffset()
1555 if not tzoff: # zero or None
1556 self._hashcode = hash(t._getstate()[0])
1557 else:
1558 h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
1559 timedelta(hours=1))
1560 assert not m % timedelta(minutes=1), "whole minute"
1561 m //= timedelta(minutes=1)
1562 if 0 <= h < 24:
1563 self._hashcode = hash(time(h, m, self.second, self.microsecond))
1564 else:
1565 self._hashcode = hash((h, m, self.second, self.microsecond))
1566 return self._hashcode
1567
1568 # Conversion to string
1569

Callers

nothing calls this directly

Calls 7

replaceMethod · 0.95
hashFunction · 0.85
timedeltaClass · 0.85
timeClass · 0.70
divmodFunction · 0.50
utcoffsetMethod · 0.45
_getstateMethod · 0.45

Tested by

no test coverage detected