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

Simplify and speed-up math.hypot() and math.dist() by rhettinger · Pull Request #102734 · python/cpython · GitHub

/ cpython Public

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

Merged
rhettinger merged 6 commits into
python:mainfrom
rhettinger:faster_hypot
Mar 15, 2023
Merged

Simplify and speed-up math.hypot() and math.dist()#102734
rhettinger merged 6 commits into
python:mainfrom
rhettinger:faster_hypot

Conversation

rhettinger commented Mar 15, 2023
edited
Loading

Copy link
Copy Markdown
Contributor

Apply the sumprod() DoubleLength functions to vector_norm() which is called by both hypot() and dist().

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

rhettinger merged commit 0a22aa0 into python:main Mar 15, 2023
Fidget-Spinner pushed a commit to Fidget-Spinner/cpython that referenced this pull request Mar 27, 2023
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
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

Labels

3.12 only security fixes performance Performance or resource usage skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL