◐ Shell
clean mode source ↗

gh-142927: Show module names instead of file paths in flamegraph by ivonastojanovic · Pull Request #146040 · python/cpython

pablogsal

pablogsal

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.
Rename "Full Paths" to "File Paths", remove basename-only
.split('/').pop() so tooltip, hotspots, and search all show the
same path in file-paths mode.