Skip to content

Commit 9aa8629

Browse files
committed
Use same colour for raw time commas as arrows
1 parent 10b19ad commit 9aa8629

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

Lib/_colorize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class Timeit(ThemeSection):
328328
timing: str = ANSIColors.CYAN
329329
best: str = ANSIColors.BOLD_GREEN
330330
per_loop: str = ANSIColors.GREEN
331-
arrow: str = ANSIColors.GREY
331+
punctuation: str = ANSIColors.GREY
332332
warning: str = ANSIColors.YELLOW
333333
warning_worst: str = ANSIColors.MAGENTA
334334
warning_best: str = ANSIColors.GREEN

Lib/test/test_timeit.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,13 @@ def test_main_verbose_colorized(self):
429429
s = self.run_main(switches=["-v"])
430430
self.assertEqual(
431431
s,
432-
f"1 loop {t.arrow}-> {t.timing}1 secs{t.reset}\n\n"
432+
f"1 loop {t.punctuation}-> {t.timing}1 secs{t.reset}\n\n"
433433
"raw times: "
434-
f"{t.timing}1 sec, 1 sec, 1 sec, 1 sec, 1 sec{t.reset}\n\n"
434+
f"{t.timing}1 sec{t.punctuation}, "
435+
f"{t.timing}1 sec{t.punctuation}, "
436+
f"{t.timing}1 sec{t.punctuation}, "
437+
f"{t.timing}1 sec{t.punctuation}, "
438+
f"{t.timing}1 sec{t.reset}\n\n"
435439
f"1 loop, best of 5: {t.best}1 sec{t.reset} "
436440
f"{t.per_loop}per loop{t.reset}\n",
437441
)

Lib/timeit.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def callback(number, time_taken):
342342
s = "" if number == 1 else "s"
343343
print(
344344
f"{number} loop{s} "
345-
f"{theme.arrow}-> "
345+
f"{theme.punctuation}-> "
346346
f"{theme.timing}{time_taken:.{precision}g} secs{reset}"
347347
)
348348

@@ -376,8 +376,10 @@ def format_time(dt):
376376
return "%.*g %s" % (precision, dt / scale, unit)
377377

378378
if verbose:
379-
raw = ", ".join(map(format_time, raw_timings))
380-
print(f"raw times: {theme.timing}{raw}{reset}")
379+
raw = f"{theme.punctuation}, ".join(
380+
f"{theme.timing}{t}" for t in map(format_time, raw_timings)
381+
)
382+
print(f"raw times: {raw}{reset}")
381383
print()
382384
timings = [dt / number for dt in raw_timings]
383385

0 commit comments

Comments
 (0)