Timer usable as with Timer() as t: that records time.perf_counter() on entry and sets t.elapsed (seconds) on exit — even when the body raises (do not suppress the exception; return False/None from __exit__).with Timer() as t:\n work()\nprint(t.elapsed > 0)
True
__exit__ always stamps the elapsed time.
__enter__ returns self so "as t" binds the instance.
__exit__(self, exc_type, exc, tb) computes elapsed unconditionally.