def __sub__(self, other: Snapshot) -> Snapshot: if not isinstance(other, Snapshot): return NotImplemented return Snapshot( posix.times_result(t0 - t1 for t0, t1 in zip(self.process, other.process)))
def null(cls) -> Snapshot: return cls(posix.times_result((0.0, 0.0, 0.0, 0.0, 0.0)))
def deserialize(cls, serialized: object) -> Snapshot: try: assert isinstance(serialized, dict) return cls(posix.times_result(serialized["process"])) except LookupError as exc: raise ValueError(serialized) from exc
def times_result(seq: Iterable[float]) -> posix.times_result: # mypy warnings are false positives. return posix.times_result(tuple(seq)) # type: ignore[arg-type, call-arg]