Skip to content

Document new profiling package and restructure the profiler docs according to PEP 799 #140727

Description

@dimaqq

Documentation

The doc states at https://docs.python.org/3.15/whatsnew/3.15.html#pep-799-high-frequency-statistical-sampling-profiler:

Profile process 1234 for 10 seconds with default settings:

python -m profiling.sampling 1234

At least on macOS, the argument "1234" is interpreted as a Python script to run, not a PID:

(jgol-peer) 🦐/c/j/peer (main)> sudo -E env PYTHONPATH=src python -m profiling.sampling 1234
Profiler coordinator error: Script not found: /code/jgol/peer/1234
...
...
TypeError: Cannot create or construct a <class 'pstats.SampledStats'> object from <profiling.sampling.pstats_collector.PstatsCollector object at 0x1036441a0>

Meanwhile a Python script is accepted:

(jgol-peer) 🦐/c/j/peer (main)> echo "import ops" > foo.py
(jgol-peer) 🦐/c/j/peer (main)> sudo -E env PYTHONPATH=src python -m profiling.sampling foo.py
Captured 586 samples in 0.06 seconds
Sample rate: 10000.02 samples/sec
Error rate: 7.17%
Profile Stats:
...
...

Linked PRs

Activity

  1. StanFromIreland commented on Oct 28, 2025

    @StanFromIreland
    Member
  2. pablogsal commented on Oct 29, 2025

    @pablogsal
    Member

    Ah this is out of date! Thanks for bringing it up. We are changing this quite a bit, and once the this stabilizes we will update back the what's new hopefully before the next alpha. You can always run `python3.15 -m profiling.sampling -h to know exactly what it takes"

  3. terryjreedy commented on Dec 6, 2025

    @terryjreedy
    Member

    I suggest that this issue be broadened into "Document new profiling package" as there is nothing now in module list and index. Importing profiling, profiling.sampling (new subpackage), and profiling.tracing (package that replaces profile (and CProfile?) modules) and calling help result in an output that directs one to non-existent https://docs.python.org/3.15/library/profiling.html, etc. The long What's new entry should be moved to a new sampling.rst and replaced in What's New with a link to the new .html.

  4. pablogsal commented on Dec 6, 2025

    @pablogsal
    Member

    I suggest that this issue be broadened into "Document new profiling package" as there is nothing now in module list and index.

    Indeed. We have planned a whole Docs overhaul once development stars to stabilize and we have a fixed list of things. We are planing some docs on understanding sampling profiling + a profiling HOWTO.

    Importing profiling, profiling.sampling (new subpackage), and profiling.tracing (package that replaces profile (and CProfile?) modules) and calling help result in an output that directs one to non-existent https://docs.python.org/3.15/library/profiling.html, etc.

    I am not sure where is the 'redirect'. Can you point to where you are seeing that redirect to the docs?

    The long What's new entry should be moved to a new sampling.rst and replaced in What's New with a link to the new .html.

    Agreed. This will be done once we have the docs in place

  5. pablogsal commented on Dec 6, 2025

    @pablogsal
    Member
  6. changed the title [-]3.15 what's new profiling example arguments seem incorrect[/-] [+]Document new profiling package[/+] on Dec 6, 2025
  7. self-assigned this
    on Dec 6, 2025
  8. gpshead commented on Dec 7, 2025

    @gpshead
    Member

    what terry said... but also I assume this is work in progress. 😁 it was a bit confusing to look at the https://docs.python.org/3.15/library/profile.html and see a link to a non-existantLib/profile/sample.py file and an unlinked presumed not-yet-existant profiling.sampling reference.

  9. changed the title [-]Document new profiling package[/-] [+]Document new profiling package and restructure the profiler docs according to PEP 799[/+] on Dec 7, 2025
  10. pablogsal commented on Dec 7, 2025

    @pablogsal
    Member

    Here we go #142373

  11. added 3 commits that reference this issue on Dec 7, 2025
  12. added 2 commits that reference this issue on Apr 24, 2026
  13. added a commit that references this issue on Apr 25, 2026
  14. added a commit that references this issue on Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.15bugs and security fixesdocsDocumentation in the Doc dirtopic-profiling

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions