Skip to content

gh-136066: simplify platform._platform() #136069

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Jun 28, 2025

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Can you please provide a benchmark for realistical platforms and some unrealistically big ones?

@picnixz
Copy link
Member Author

picnixz commented Jun 28, 2025

Can you please provide a benchmark for realistical platforms and some unrealistically big ones?

For realistic ones, there should be no difference (because the strings are REALLY small). For unrealistically big ones, I'll write them.

@picnixz picnixz changed the title gh-136066: reduce asymptotic complexity of platform._platform() gh-136066: simplify platform._platform() Jun 28, 2025
@picnixz picnixz added the type-refactor Code refactoring (with no changes in behavior) label Jun 28, 2025
@picnixz
Copy link
Member Author

picnixz commented Jun 28, 2025

For the benchmarks:

./python -m pyperf timeit -s 'import platform; s="-" *1_000_000' 'platform._platform(s)'

On a PGO+LTO build:

Mean +- std dev: [ref] 5.83 ms +- 0.12 ms -> [new] 881 us +- 11 us: 6.62x faster

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Awesome results! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting merge skip news type-refactor Code refactoring (with no changes in behavior)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants