Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simplify and speed-up math.hypot() and math.dist()#102734

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rhettinger merged 6 commits intopython:mainfromrhettinger:faster_hypot
Mar 15, 2023

Conversation

@rhettinger
Copy link
Contributor

@rhettingerrhettinger commentedMar 15, 2023
edited
Loading

Apply thesumprod() DoubleLength functions tovector_norm() which is called by bothhypot() anddist().

Baseline timing

% ./python.exe -m timeit -r11 -s 'from random import expovariate as r' -s 'from math import hypot' -s 'n=100' -s 'data = [r() for i in range(n)]' 'hypot(*data)'500000 loops, best of 11: 579 nsec per loop

Timing with PR

% ./python.exe -m timeit -r11 -s 'from random import expovariate as r' -s 'from math import hypot' -s 'n=100' -s 'data = [r() for i in range(n)]' 'hypot(*data)'500000 loops, best of 11: 476 nsec per loop

Timing with PR if fma() is not used

% ./python.exe -m timeit -r11 -s 'from random import expovariate as r' -s 'from math import hypot' -s 'n=100' -s 'data = [r() for i in range(n)]' 'hypot(*data)'500000 loops, best of 11: 531 nsec per loop

@rhettingerrhettinger merged commit0a22aa0 intopython:mainMar 15, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull requestMar 27, 2023
warsaw pushed a commit to warsaw/cpython that referenced this pull requestApr 11, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

3.12only security fixesperformancePerformance or resource usageskip issueskip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@rhettinger@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp