Skip to content

Possible performance improvement in list repeating #92285

@thatbirdguythatuknownot

Description

@thatbirdguythatuknownot

Bug report

List repeating can be optimized a bit by using the same algorithm/method as _PyBytes_Repeat:

python_original -m timeit -s "l = [*range(100)]" "l * 100"
5000 loops, best of 5: 31.9 usec per loop

python_modified -m timeit -s "l = [*range(100)]" "l * 100"
5000 loops, best of 5: 25.9 usec per loop

Your environment

  • CPython versions tested on: 3.11.0a7+
  • Operating system and architecture: Windows 10 64-bit

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions