python / cpython

The Python programming language
https://www.python.org
Other
63.31k stars 30.31k forks source link

int/float specializations should mutate the LHS in-place when possible #90530

Open brandtbucher opened 2 years ago

brandtbucher commented 2 years ago
BPO 46372
Nosy @gvanrossum, @mdickinson, @markshannon, @brandtbucher
PRs
  • python/cpython#30594
  • 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: ```python assignee = 'https://github.com/brandtbucher' closed_at = None created_at = labels = ['interpreter-core', '3.11', 'performance'] title = 'int/float specializations should mutate the LHS in-place when possible' updated_at = user = 'https://github.com/brandtbucher' ``` bugs.python.org fields: ```python activity = actor = 'gvanrossum' assignee = 'brandtbucher' closed = False closed_date = None closer = None components = ['Interpreter Core'] creation = creator = 'brandtbucher' dependencies = [] files = [] hgrepos = [] issue_num = 46372 keywords = ['patch'] message_count = 2.0 messages = ['410544', '412215'] nosy_count = 4.0 nosy_names = ['gvanrossum', 'mark.dickinson', 'Mark.Shannon', 'brandtbucher'] pr_nums = ['30594'] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = 'performance' url = 'https://bugs.python.org/issue46372' versions = ['Python 3.11'] ```

    brandtbucher commented 2 years ago

    The performance of our existing int and float specializations can be improved by mutating the LHS operand in-place when possible. This leads to significant speedups for several number-crunching benchmarks, and a solid 1% improvement overall:

    Slower (16):

    Faster (24):

    Benchmark hidden because not significant (18): chameleon, django_template, logging_simple, mako, meteor_contest, pathlib, pyflate, regex_compile, richards, scimark_sor, sqlite_synth, sympy_expand, sympy_str, tornado_http, unpickle, unpickle_list, xml_etree_parse, xml_etree_iterparse

    Geometric mean: 1.01x faster

    gvanrossum commented 2 years ago

    Since we decided to wait on the int operations while longobject.c is being refactored (https://github.com/faster-cpython/ideas/issues/245), can you clarify whether the speedup reported is from code where it is implemented only for floats, or is it from a prototype where it's implemented for floats and ints?