From ff7f62eb2333ac2a2ce2726ba1763bf2fa1956e2 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Mon, 22 Dec 2025 16:15:57 +0200 Subject: [PATCH 1/5] gh-142927: Tachyon: Comma separate thousands and fix singular/plurals (#142934) --- Lib/profiling/sampling/_format_utils.py | 5 ++ .../sampling/_heatmap_assets/heatmap.js | 4 +- Lib/profiling/sampling/cli.py | 11 +++++ Lib/profiling/sampling/heatmap_collector.py | 46 ++++++++++--------- Lib/profiling/sampling/sample.py | 44 ++++++++---------- 5 files changed, 64 insertions(+), 46 deletions(-) create mode 100644 Lib/profiling/sampling/_format_utils.py diff --git a/Lib/profiling/sampling/_format_utils.py b/Lib/profiling/sampling/_format_utils.py new file mode 100644 index 00000000000000..237a4f4186bf20 --- /dev/null +++ b/Lib/profiling/sampling/_format_utils.py @@ -0,0 +1,5 @@ +import locale + + +def fmt(value: int | float, decimals: int = 1) -> str: + return locale.format_string(f'%.{decimals}f', value, grouping=True) diff --git a/Lib/profiling/sampling/_heatmap_assets/heatmap.js b/Lib/profiling/sampling/_heatmap_assets/heatmap.js index 90b5b111d36a8f..53928b7b20fb11 100644 --- a/Lib/profiling/sampling/_heatmap_assets/heatmap.js +++ b/Lib/profiling/sampling/_heatmap_assets/heatmap.js @@ -577,10 +577,12 @@ function populateBytecodePanel(panel, button) { else if (specPct >= 33) specClass = 'medium'; // Build specialization summary + const instruction_word = instructions.length === 1 ? 'instruction' : 'instructions'; + const sample_word = totalSamples === 1 ? 'sample' : 'samples'; let html = `