GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-138122: Add sampling profiler visualisation to docs by lkollar · Pull Request #142772 · python/cpython

Conversation

@lkollar

@lkollar lkollar commented Dec 15, 2025 •
edited by StanFromIreland
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Add a visualisation explaining how the sampling profiler works.

image

CC: @pablogsal

  • Issue: Implement PEP 799 – A dedicated profiling package for organizing Python profiling tools #138122

📚 Documentation preview 📚: https://cpython-previews--142772.org.readthedocs.build/en/142772/library/profiling.sampling.html

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lkollar
Add sampling profiler visualisation
17ed565
Add an interactive JS visualisation to demonstrate how the sampling
profiler works. A small demo program is shown executing line by line,
demonstrating how stack frames are created and destroyed and how samples
are taken periodically during the process.

A new Sphinx extension is used to capture and inject the trace into the
JS file during documentation build to make these traces reproducible
(and avoid hard coding them in the source code).
@lkollar
lkollar requested review from AA-Turner, hugovk and pablogsal as code owners December 15, 2025 22:17
@bedevere-app bedevere-app Bot added the awaiting review label Dec 15, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Dec 15, 2025
Implement PEP 799 – A dedicated profiling package for organizing Python profiling tools #138122
Closed
StanFromIreland
StanFromIreland reviewed Dec 15, 2025
View reviewed changes
Comment thread Doc/library/profiling.sampling.rst
.. only:: html

The following interactive visualization demonstrates how sampling profiling
works. Press **Play** to watch a Python program execute, and observe how the

@StanFromIreland StanFromIreland Dec 15, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the :guilabel: role for buttons.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@lkollar lkollar Dec 16, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using this but it just wraps the element in a span and has no associated styling, so the text isn't highlighted in any way. I could style it in the local CSS but this should probably get a global style rule.

The only other place where this is used is in the logging cookbook (search for "Download ZIP") which isn't styled either. Seems like a bug to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lkollar added 2 commits December 16, 2025 10:33
@lkollar
Fix unclosed tag
6535df5
@lkollar
Fix epub export issue
65048f0
Include the JS and CSS files in the Sphinx extension to make sure Sphinx
properly includes these when producing all output types.
@StanFromIreland StanFromIreland added the skip news label Dec 16, 2025
@pablogsal
Simplify sampling profiler visualization code
e34d607
Moved function colors to a lookup map and easing definitions to a module
constant so they aren't recreated on each call. Cached the background
element reference in DOMStackFrame instead of querying it on every
hover. Chained the regex replacements in syntax highlighting into one
expression.

Removed the CSS color rules for specific functions since colors are now
set in JS, along with a duplicate color variable and two methods that
were never called.
@pablogsal

pablogsal commented Dec 23, 2025

Copy link
Copy Markdown
Member

@hugovk @AA-Turner could you give this a pass if you have some time? We would love your insights!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
pablogsal merged commit d18dbd5 into python:main Feb 10, 2026
28 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting review label Feb 10, 2026
@pablogsal

pablogsal commented Feb 10, 2026

Copy link
Copy Markdown
Member

Thanks a lot for the great work @lkollar!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@lkollar @pablogsal @thunder-coding
pythongh-138122: Add sampling profiler visualisation to docs (python#…
60f162d
…142772)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
brijkapadia pushed a commit to brijkapadia/cpython that referenced this pull request Feb 28, 2026
@lkollar @pablogsal @brijkapadia
pythongh-138122: Add sampling profiler visualisation to docs (python#…
25648d5
…142772)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
@lkollar @pablogsal @ljfp
pythongh-138122: Add sampling profiler visualisation to docs (python#…
4cab28f
…142772)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@StanFromIreland StanFromIreland StanFromIreland left review comments
@pablogsal pablogsal Awaiting requested review from pablogsal pablogsal is a code owner
@AA-Turner AA-Turner Awaiting requested review from AA-Turner AA-Turner is a code owner
@hugovk hugovk Awaiting requested review from hugovk hugovk is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@lkollar @pablogsal @StanFromIreland
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.