gh-142927: Show module names instead of file paths in flamegraph by ivonastojanovic · Pull Request #146040 · python/cpython
Move module name extraction logic from heatmap_collector to shared module_utils to enable flamegraph to display module names instead of full file paths.
Display module names instead of full file paths (/home/user/project/pkg/mod.py → pkg.mod) in flamegraph for readability.
Users can now switch between module names and file paths using the toggle in the View Mode sidebar. Module names are concise, while file paths help locate the exact source file, both are useful depending on the debugging context.
_path_to_module included the root separator (/ or drive letter) when converting absolute paths to dotted module names, producing /.tmp.project.main instead of tmp.project.main.
Replace _is_subpath helper with Path.is_relative_to() (available since 3.9), removing the double relative_to() call.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters