Issue34152
Created on 2018-07-18 18:26 by sir-sigurd, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 8333 | closed | sir-sigurd, 2018-07-18 18:27 | |
| Messages (5) | |||
|---|---|---|---|
| msg321908 - (view) | Author: Sergey Fedoseev (sir-sigurd) * | Date: 2018-07-18 18:26 | |
Script for benchmarks: NAME=list-slice.json python -m perf timeit --name "l[len(l):] = reversed(l)" -l 1 -s "l = [None] * 1000000" "l[len(l):] = reversed(l)" --append $NAME python -m perf timeit --name "l[len(l):] = l" -l 1 -s "l = [None] * 1000000" "l[len(l):] = l" --append $NAME python -m perf timeit --name "l[::-1] = l" -s "l = [None] * 1000000" "l[::-1] = l" --append $NAME python -m perf timeit --name "l[:] = l" -s "l = [None] * 1000000" "l[:] = l" --append $NAME python -m perf timeit --name "l[len(l)//2:] = l" -l 1 -s "l = [None] * 1000000" "l[len(l)//2:] = l" --append $NAME python -m perf timeit --name "l[:len(l)//2] = l" -l 1 -s "l = [None] * 1000000" "l[:len(l)//2] = l" --append $NAME python -m perf timeit --name "l[len(l)//4:len(l)*3//4] = l" -l 1 -s "l = [None] * 1000000" "l[len(l)//4:len(l)*3//4] = l" --append $NAME Results table: +------------------------------+-------------------+------------------------------------+ | Benchmark | list-slice-master | list-slice | +==============================+===================+====================================+ | l[len(l):] = reversed(l) | 8.44 ms | 5.18 ms: 1.63x faster (-39%) | +------------------------------+-------------------+------------------------------------+ | l[len(l):] = l | 7.88 ms | 3.37 ms: 2.34x faster (-57%) | +------------------------------+-------------------+------------------------------------+ | l[::-1] = l | 10.4 ms | 582 us: 17.85x faster (-94%) | +------------------------------+-------------------+------------------------------------+ | l[:] = l | 10.6 ms | 86.1 ns: 123128.46x faster (-100%) | +------------------------------+-------------------+------------------------------------+ | l[len(l)//2:] = l | 11.1 ms | 2.08 ms: 5.33x faster (-81%) | +------------------------------+-------------------+------------------------------------+ | l[:len(l)//2] = l | 11.5 ms | 1.76 ms: 6.53x faster (-85%) | +------------------------------+-------------------+------------------------------------+ | l[len(l)//4:len(l)*3//4] = l | 11.3 ms | 2.27 ms: 4.98x faster (-80%) | +------------------------------+-------------------+------------------------------------+ |
|||
| msg321924 - (view) | Author: Raymond Hettinger (rhettinger) * ![]() |
Date: 2018-07-19 05:26 | |
I recommend against this one. The cases covered are too exotic to care about and don't warrant the code churn. |
|||
| msg339742 - (view) | Author: Cheryl Sabella (cheryl.sabella) * ![]() |
Date: 2019-04-09 13:05 | |
@rhettinger recommended against this suggestion last July. I'm bumping this for others to comment and to recommend closing the issue and PR if it's not going to move forward. Nosying Pablo since he commented on the PR. |
|||
| msg339744 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2019-04-09 13:22 | |
I concur with Raymond. |
|||
| msg342236 - (view) | Author: Pablo Galindo Salgado (pablogsal) * ![]() |
Date: 2019-05-12 03:20 | |
I concur with Raymond and Serhiy: this patch covers very exotic cases and complicates the surrounding code. I'm closing this issue. Thanks, @sir-sigurd for the proposal |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:03 | admin | set | github: 78333 |
| 2019-05-12 03:20:31 | pablogsal | set | status: open -> closed resolution: rejected messages: + msg342236 stage: patch review -> resolved |
| 2019-04-09 13:22:53 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg339744 |
| 2019-04-09 13:05:16 | cheryl.sabella | set | nosy:
+ pablogsal, cheryl.sabella messages: + msg339742 |
| 2018-07-19 05:26:31 | rhettinger | set | nosy:
+ rhettinger messages: + msg321924 |
| 2018-07-19 03:54:57 | sir-sigurd | set | title: performance of some list slice assignment can be improved -> performance of some list slice assignment margin cases can be improved |
| 2018-07-18 18:27:31 | sir-sigurd | set | keywords:
+ patch stage: patch review pull_requests: + pull_request7870 |
| 2018-07-18 18:26:09 | sir-sigurd | create | |
