https://github.com/python/cpython/commit/43b0e01b5098c9e796957c10a992d8e6e95e0ae1
commit: 43b0e01b5098c9e796957c10a992d8e6e95e0ae1
branch: main
author: Ćukasz <[email protected]>
committer: pablogsal <[email protected]>
date: 2026-07-11T18:44:31+01:00
summary:
gh-153293: Clear opcode statistics in the live profiler's reset_stats()
(#153295)
files:
A Misc/NEWS.d/next/Library/2026-07-07-22-06-52.gh-issue-153293.0DvYdc.rst
M Lib/profiling/sampling/live_collector/collector.py
M
Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py
diff --git a/Lib/profiling/sampling/live_collector/collector.py
b/Lib/profiling/sampling/live_collector/collector.py
index 2805134f239eb38..553c856c6f8c562 100644
--- a/Lib/profiling/sampling/live_collector/collector.py
+++ b/Lib/profiling/sampling/live_collector/collector.py
@@ -702,6 +702,7 @@ def build_stats_list(self):
def reset_stats(self):
"""Reset all collected statistics."""
self.result.clear()
+ self.opcode_stats.clear()
self.per_thread_data.clear()
self.thread_ids.clear()
self.view_mode = "ALL"
diff --git
a/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py
b/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py
index baf478133fc6659..6dfdb9a192e03a1 100644
---
a/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py
+++
b/Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py
@@ -99,6 +99,7 @@ def test_reset_stats(self):
"cumulative_calls": 75,
"total_rec_calls": 0,
}
+ self.collector.opcode_stats[("test.py", 1, "func")][100] = 5
# Reset
self.collector.reset_stats()
@@ -107,6 +108,7 @@ def test_reset_stats(self):
self.assertEqual(self.collector.successful_samples, 0)
self.assertEqual(self.collector.failed_samples, 0)
self.assertEqual(len(self.collector.result), 0)
+ self.assertEqual(len(self.collector.opcode_stats), 0)
def test_increase_refresh_rate(self):
"""Test increasing refresh rate (faster updates)."""
diff --git
a/Misc/NEWS.d/next/Library/2026-07-07-22-06-52.gh-issue-153293.0DvYdc.rst
b/Misc/NEWS.d/next/Library/2026-07-07-22-06-52.gh-issue-153293.0DvYdc.rst
new file mode 100644
index 000000000000000..ac358bb7fc0a507
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2026-07-07-22-06-52.gh-issue-153293.0DvYdc.rst
@@ -0,0 +1,2 @@
+Fix the live sampling profiler TUI keeping stale aggregated opcode
+statistics after a stats reset.
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]