Skip to content

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!

@picnixz picnixz merged commit bd928a3 into python:main Jun 29, 2025
45 checks passed
@picnixz picnixz deleted the refactor/platform/strip-136066 branch June 29, 2025 07:56
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull request Jul 11, 2025
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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