Skip to content
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

Optimize multi-argument math functions #79900

Closed
serhiy-storchaka opened this issue Jan 11, 2019 · 2 comments
Closed

Optimize multi-argument math functions #79900

serhiy-storchaka opened this issue Jan 11, 2019 · 2 comments
Labels
3.8 only security fixes extension-modules C modules in the Modules dir performance Performance or resource usage

Comments

@serhiy-storchaka
Copy link
Member

BPO 35719
Nosy @rhettinger, @mdickinson, @vstinner, @serhiy-storchaka
PRs
  • bpo-35719: Optimize multi-argument math functions. #11527
  • bpo-35719: Optimize multi-argument math functions. #11527
  • bpo-35719: Optimize multi-argument math functions. #11527
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-01-12.06:27:16.330>
    created_at = <Date 2019-01-11.18:17:24.899>
    labels = ['extension-modules', '3.8', 'performance']
    title = 'Optimize multi-argument math functions'
    updated_at = <Date 2019-01-12.06:27:16.330>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2019-01-12.06:27:16.330>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-01-12.06:27:16.330>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2019-01-11.18:17:24.899>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35719
    keywords = ['patch', 'patch', 'patch']
    message_count = 2.0
    messages = ['333497', '333514']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'mark.dickinson', 'vstinner', 'stutzbach', 'serhiy.storchaka']
    pr_nums = ['11527', '11527', '11527']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue35719'
    versions = ['Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    The proposed PR makes multi-argument functions in the math module atan2(), copysign(), remainder() and hypot() to use the fast call convention and inline arguments tuple unpacking.

    Results:

    $ ./python -m timeit -s "from math import atan2" "atan2(1.0, 1.0)"
    Unpatched:  5000000 loops, best of 5: 79.5 nsec per loop
    Patched:    5000000 loops, best of 5: 66.1 nsec per loop
    
    $ ./python -m timeit -s "from math import copysign" "copysign(1.0, 1.0)"
    Unpatched:  5000000 loops, best of 5: 90.3 nsec per loop
    Patched:    10000000 loops, best of 5: 35.9 nsec per loop
    
    $ ./python -m timeit -s "from math import remainder" "remainder(1.0, 1.0)"
    Unpatched:  5000000 loops, best of 5: 69.5 nsec per loop
    Patched:    5000000 loops, best of 5: 44.5 nsec per loop
    
    $ ./python -m timeit -s "from math import hypot" "hypot(1.0, 1.0)"
    Unpatched:  5000000 loops, best of 5: 63.6 nsec per loop
    Patched:    5000000 loops, best of 5: 47.4 nsec per loop

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes extension-modules C modules in the Modules dir performance Performance or resource usage labels Jan 11, 2019
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset d0d3e99 by Serhiy Storchaka in branch 'master':
    bpo-35719: Optimize multi-argument math functions. (GH-11527)
    d0d3e99

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes extension-modules C modules in the Modules dir performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant