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

Improve performance of bytes_repeat #91161

Closed
eendebakpt mannequin opened this issue Mar 13, 2022 · 3 comments
Closed

Improve performance of bytes_repeat #91161

eendebakpt mannequin opened this issue Mar 13, 2022 · 3 comments
Labels
3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage

Comments

@eendebakpt
Copy link
Mannequin

eendebakpt mannequin commented Mar 13, 2022

BPO 47005
Nosy @sweeneyde, @eendebakpt
PRs
  • bpo-47005: Improve performance of bytearray_repeat and bytearray_irepeat #31856
  • 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 2022-03-17.23:11:56.249>
    created_at = <Date 2022-03-13.19:01:26.638>
    labels = ['interpreter-core', '3.11', 'performance']
    title = 'Improve performance of bytes_repeat'
    updated_at = <Date 2022-03-17.23:11:56.249>
    user = 'https://github.com/eendebakpt'

    bugs.python.org fields:

    activity = <Date 2022-03-17.23:11:56.249>
    actor = 'Dennis Sweeney'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-03-17.23:11:56.249>
    closer = 'Dennis Sweeney'
    components = ['Interpreter Core']
    creation = <Date 2022-03-13.19:01:26.638>
    creator = 'pieter.eendebak'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 47005
    keywords = ['patch']
    message_count = 3.0
    messages = ['415077', '415457', '415458']
    nosy_count = 3.0
    nosy_names = ['python-dev', 'Dennis Sweeney', 'pieter.eendebak']
    pr_nums = ['31856']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue47005'
    versions = ['Python 3.11']

    @eendebakpt
    Copy link
    Mannequin Author

    eendebakpt mannequin commented Mar 13, 2022

    The bytearray_repeat and bytearray_irepeat are inefficient for small arrays and a high number of repeats.
    This can be improved by using the same approach is in the corresponding bytes_repeat method.

    Microbenchmark:

    python -m pyperf timeit "b=bytearray([1,2,])*100"

    Mean +- std dev: [base100] 479 ns +- 29 ns -> [patch100] 274 ns +- 18 ns: 1.75x faster

    python -m pyperf timeit "b=bytearray([1,2,])*1000"

    Mean +- std dev: [base1000] 2.58 us +- 0.18 us -> [patch1000] 399 ns +- 26 ns: 6.46x faster

    @eendebakpt eendebakpt mannequin added 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage labels Mar 13, 2022
    @sweeneyde
    Copy link
    Member

    New changeset ac8308d by Pieter Eendebak in branch 'main':
    bpo-47005: Improve performance of bytearray_repeat and bytearray_irepeat (GH-31856)
    ac8308d

    @sweeneyde
    Copy link
    Member

    Thanks for the contribution -- that's a really nice speedup.

    @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.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant