Skip to content

Conversation

@rhettinger
Copy link
Contributor

@rhettingerrhettinger commented Mar 15, 2023

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 

@rhettingerrhettinger merged commit 0a22aa0 into python:mainMar 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
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.12only security fixesperformancePerformance or resource usageskip issueskip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@rhettinger@bedevere-bot