Skip to content

Commit d0cdeb4

Browse files
committed
Directly use time.monotonic
It's always available starting with Python 3.5.
1 parent 1b3c87e commit d0cdeb4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

bpython/repl.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,17 @@ class RuntimeTimer:
6565

6666
def __init__(self) -> None:
6767
self.reset_timer()
68-
self.time = time.monotonic if hasattr(time, "monotonic") else time.time
6968

7069
def __enter__(self) -> None:
71-
self.start = self.time()
70+
self.start = time.monotonic()
7271

7372
def __exit__(
7473
self,
7574
exc_type: Optional[Type[BaseException]],
7675
exc_val: Optional[BaseException],
7776
exc_tb: Optional[TracebackType],
7877
) -> Literal[False]:
79-
self.last_command = self.time() - self.start
78+
self.last_command = time.monotonic() - self.start
8079
self.running_time += self.last_command
8180
return False
8281

0 commit comments

Comments
 (0)