Author sir-sigurd
Recipients sir-sigurd
Date 2018-07-18.18:26:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531938369.41.0.56676864532.issue34152@psf.upfronthosting.co.za>
In-reply-to
Content
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%)       |
+------------------------------+-------------------+------------------------------------+
History
Date User Action Args
2018-07-18 18:26:09sir-sigurdsetrecipients: + sir-sigurd
2018-07-18 18:26:09sir-sigurdsetmessageid: <1531938369.41.0.56676864532.issue34152@psf.upfronthosting.co.za>
2018-07-18 18:26:09sir-sigurdlinkissue34152 messages
2018-07-18 18:26:08sir-sigurdcreate