Skip to content
Prev Previous commit
Next Next commit
comment, simplify
  • Loading branch information
jbrockmendel committed Apr 10, 2022
commit 4aee01a174acd147211944f00401e8bd9a5af26d
12 changes: 6 additions & 6 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -907,12 +907,12 @@ cdef class _Timedelta(timedelta):

def __hash__(_Timedelta self):
if self._has_ns():
if self._reso == NPY_FR_ns:
return hash(self.value)
else:
# TODO: more performant way to do this? same problem for Timestamp
# Invariances we are supposed to preserve?
return hash((self.value, self._reso))
# Note: this does *not* satisfy the invariance
# td1 == td2 \\Rightarrow hash(td1) == hash(td2)
# if td1 and td2 have different _resos. timedelta64 also has this
# non-invariant behavior.
# see GH#44504
return self.value
else:
return timedelta.__hash__(self)

Expand Down