Avoid timestamp conversion in core State when equal to last_updated (#114911)

This commit is contained in:
J. Nick Koston 2024-04-04 20:27:27 -10:00 committed by GitHub
parent 5447a1a015
commit 0e2fe3b728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1680,11 +1680,15 @@ class State:
@cached_property
def last_changed_timestamp(self) -> float:
"""Timestamp of last change."""
if self.last_changed == self.last_updated:
return self.last_updated_timestamp
return self.last_changed.timestamp()
@cached_property
def last_reported_timestamp(self) -> float:
"""Timestamp of last report."""
if self.last_reported == self.last_updated:
return self.last_updated_timestamp
return self.last_reported.timestamp()
@cached_property