Skip to content

gh-158986: Fix profiling.sampling module type for nested site-packages - #158993

Open
sricursion wants to merge 1 commit into
python:mainfrom
sricursion:profiling-site-packages-in-stdlib
Open

sricursion wants to merge 1 commit into
python:mainfrom
sricursion:profiling-site-packages-in-stdlib

Conversation

@sricursion

@sricursion sricursion commented Oct 7, 2026 •

Copy link
Copy Markdown

extract_module_name() checked the stdlib directory before the site-packages directories. In a regular installation site-packages is inside the stdlib directory, so files in it were reported as stdlib modules named site-packages.<module>. The heatmap index then listed them under "Standard Library" and flamegraph labels carried the site-packages. prefix. The fix collects the stdlib and site-packages directories that contain the file and uses the one with the most path components, so a stdlib file still wins over a broader entry such as sys.prefix (which site.getsitepackages() also returns on Windows), and stdlib wins a tie. The classification dates from the heatmap collector (gh-140677) and was moved to module_utils in gh-142927.

…ackages

extract_module_name() checked the stdlib directory first, so files in a
site-packages directory inside it were reported as stdlib modules. Use
the most specific matching directory instead.
@sricursion
sricursion requested a review from pablogsal as a code owner October 7, 2026 20:27
@python-cla-bot

python-cla-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant