Beispiel #1
0
 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)))
Beispiel #2
0
 def null(cls) -> Snapshot:
     return cls(posix.times_result((0.0, 0.0, 0.0, 0.0, 0.0)))
Beispiel #3
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
Beispiel #4
0
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]