FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-138122: Replace --interval with --sampling-rate by lkollar · Pull Request #143085 · python/cpython · GitHub

/ cpython Public

gh-138122: Replace --interval with --sampling-rate - #143085

Merged
pablogsal merged 2 commits into
python:mainfrom
lkollar:profiling/sample-rate-cli
Dec 24, 2025
Merged

gh-138122: Replace --interval with --sampling-rate#143085
pablogsal merged 2 commits into
python:mainfrom
lkollar:profiling/sample-rate-cli

Conversation

lkollar commented Dec 22, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Comment thread Doc/library/profiling.sampling.rst Outdated
* - Default for ``--interval`` / ``-i``
- 100 µs between samples (~10,000 samples/sec)
* - Default for ``--sampling-rate`` / ``-r``
- 10 kHz

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please update the documentation to reflect the actual 1 kHz default

help="sampling interval",
"-r",
"--sampling-rate",
type=_parse_sampling_rate,

pablogsal Dec 23, 2025
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nit: The argument is named sampling_rate but after parsing it stores the interval in microseconds, not the rate in Hz. This is kind of confusing in the rest of the code


match = _RATE_PATTERN.match(rate_str)
if not match:
raise argparse.ArgumentTypeError(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nit: Let's add a hint about spaces in the error message since "10 khz" (with space) is rejected but users might try it

Comment thread Lib/profiling/sampling/cli.py Outdated
return process


_RATE_PATTERN = re.compile(r'^(\d+(?:\.\d+)?)(hz|khz|k)?$', re.IGNORECASE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
_RATE_PATTERN = re.compile(r'^(\d+(?:\.\d+)?)(hz|khz|k)?$', re.IGNORECASE)
_RATE_PATTERN = re.compile(r'''
^ # Start of string
( # Group 1: The numeric value
\d+ # One or more digits (integer part)
(?:\.\d+)? # Optional: decimal point followed by digits
) # Examples: "10", "0.5", "100.25"
( # Group 2: Optional unit suffix
hz # "hz" - hertz
| khz # "khz" - kilohertz
| k # "k" - shorthand for kilohertz
)? # Suffix is optional (bare number = Hz)
$ # End of string
''', re.VERBOSE | re.IGNORECASE)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Haha you know how much I like to comment these :)

pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM once the documentation is updated! 🚀

Copy link
Copy Markdown
Member

@lkollar There is a conflict we need to resolve on cli.py

Sampling rate is more intuitive to the number of samples per second
taken, rather than the intervals between samples.
lkollar force-pushed the profiling/sample-rate-cli branch from 578e0cc to f392e82 Compare December 24, 2025 13:21

pablogsal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM! Great work 👌

pablogsal enabled auto-merge (squash) December 24, 2025 13:23
pablogsal merged commit d4dc3dd into python:main Dec 24, 2025
50 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL