Skip to content

gh-69990: Make Profile.print_stats support sorting by multiple values #104590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Feb 16, 2024

Conversation

furkanonder
Copy link
Contributor

@furkanonder furkanonder commented May 17, 2023

@furkanonder furkanonder changed the title gh-69990: Make Profile.print_stats support sorting by mutiple values gh-69990: Make Profile.print_stats support sorting by multiple values May 17, 2023
@furkanonder furkanonder added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Aug 6, 2023
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Please update the modules documentation.

@bedevere-app
Copy link

bedevere-app bot commented Jan 17, 2024

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@furkanonder furkanonder added the 3.13 bugs and security fixes label Jan 28, 2024
to enable multi-level sorting.

.. versionadded:: 3.13
:meth:`~Profile.print_stats` can now accept multiple sort arguments.
Copy link
Member

Choose a reason for hiding this comment

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

"can accept multiple sort arguments" looks confusing. Does print_stats('calls', 'time') or print_stats(sort='calls', sort='time') work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example:

import cProfile
from pstats import SortKey

with cProfile.Profile() as pr:
    pr.print_stats(sort=("time", "calls"))  # or pr.print_stats(sort=(SortKey.TIME, SortKey.CALLS))

I believe that adding a small example to the documentation would make it easier to understand the feature. What do you think?

furkanonder and others added 2 commits February 13, 2024 23:26
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) February 16, 2024 11:50
@serhiy-storchaka serhiy-storchaka merged commit 2a7a002 into python:main Feb 16, 2024
@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows11 Bigmem 3.x has failed when building commit 2a7a002.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1079/builds/3417) and take a look at the build logs.
  4. Check if the failure is related to this commit (2a7a002) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1079/builds/3417

Summary of the results of the build (if available):

Click to see traceback logs
remote: Enumerating objects: 15, done.        
remote: Counting objects:   7% (1/14)        
remote: Counting objects:  14% (2/14)        
remote: Counting objects:  21% (3/14)        
remote: Counting objects:  28% (4/14)        
remote: Counting objects:  35% (5/14)        
remote: Counting objects:  42% (6/14)        
remote: Counting objects:  50% (7/14)        
remote: Counting objects:  57% (8/14)        
remote: Counting objects:  64% (9/14)        
remote: Counting objects:  71% (10/14)        
remote: Counting objects:  78% (11/14)        
remote: Counting objects:  85% (12/14)        
remote: Counting objects:  92% (13/14)        
remote: Counting objects: 100% (14/14)        
remote: Counting objects: 100% (14/14), done.        
remote: Compressing objects:   8% (1/12)        
remote: Compressing objects:  16% (2/12)        
remote: Compressing objects:  25% (3/12)        
remote: Compressing objects:  33% (4/12)        
remote: Compressing objects:  41% (5/12)        
remote: Compressing objects:  50% (6/12)        
remote: Compressing objects:  58% (7/12)        
remote: Compressing objects:  66% (8/12)        
remote: Compressing objects:  75% (9/12)        
remote: Compressing objects:  83% (10/12)        
remote: Compressing objects:  91% (11/12)        
remote: Compressing objects: 100% (12/12)        
remote: Compressing objects: 100% (12/12), done.        
remote: Total 15 (delta 2), reused 4 (delta 2), pack-reused 1        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '2a7a0020c9d006d268b839320979364498a5f0e6'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 2a7a0020c9 gh-69990: Make Profile.print_stats support sorting by multiple values (GH-104590)
Switched to and reset branch 'main'

Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\Lib\*.pyc
The system cannot find the file specified.
Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\PCbuild\python*.zip

Cannot open file 'R:\buildarea\3.x.ambv-bb-win11.bigmem\build\test-results.xml' for upload

The system cannot find the file specified.
Could Not Find R:\buildarea\3.x.ambv-bb-win11.bigmem\build\PCbuild\python*.zip

@ambv
Copy link
Contributor

ambv commented Feb 16, 2024

The failure is unrelated, being fixed in #115557

woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
@furkanonder furkanonder removed the 3.13 bugs and security fixes label Dec 31, 2024
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull request Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants