It's up to the reader to judge which code is more understandable. more_itertools does not have a blog post to help understand the code. nwise isn't packaged as a module - its a coding example.
Yes, well, the timing methodology is set to compare run times over a range of inputs iterable sizes and output window widths. A particular application might benefit from more specific timings.
list(nwise (range(0, 10), 1)) # 0.20s, 100000 reps
list(nwise_squashed (range(0, 10), 1)) # 0.22s, 100000 reps
list(sliding_window (range(0, 10), 1)) # 0.30s, 100000 reps
list(nwise (range(0, 10), 2)) # 0.27s, 100000 reps
list(nwise_squashed (range(0, 10), 2)) # 0.29s, 100000 reps
list(sliding_window (range(0, 10), 2)) # 0.29s, 100000 reps
list(nwise (range(0, 10), 4)) # 0.40s, 100000 reps
list(nwise_squashed (range(0, 10), 4)) # 0.43s, 100000 reps
list(sliding_window (range(0, 10), 4)) # 0.25s, 100000 reps
list(nwise (range(0, 10), 8)) # 0.76s, 100000 reps
list(nwise_squashed (range(0, 10), 8)) # 0.78s, 100000 reps
list(sliding_window (range(0, 10), 8)) # 0.20s, 100000 reps
list(nwise (range(0, 1000), 1)) # 0.21s, 5000 reps
list(nwise_squashed (range(0, 1000), 1)) # 0.21s, 5000 reps
list(sliding_window (range(0, 1000), 1)) # 0.90s, 5000 reps
list(nwise (range(0, 1000), 2)) # 0.23s, 5000 reps
list(nwise_squashed (range(0, 1000), 2)) # 0.23s, 5000 reps
list(sliding_window (range(0, 1000), 2)) # 0.94s, 5000 reps
list(nwise (range(0, 1000), 4)) # 0.26s, 5000 reps
list(nwise_squashed (range(0, 1000), 4)) # 0.28s, 5000 reps
list(sliding_window (range(0, 1000), 4)) # 0.96s, 5000 reps
list(nwise (range(0, 1000), 8)) # 0.35s, 5000 reps
list(nwise_squashed (range(0, 1000), 8)) # 0.36s, 5000 reps
list(sliding_window (range(0, 1000), 8)) # 1.03s, 5000 reps
list(nwise (range(0, 1000), 16)) # 0.56s, 5000 reps
list(nwise_squashed (range(0, 1000), 16)) # 0.56s, 5000 reps
list(sliding_window (range(0, 1000), 16)) # 1.23s, 5000 reps
list(nwise (range(0, 1000), 32)) # 1.19s, 5000 reps
list(nwise_squashed (range(0, 1000), 32)) # 1.20s, 5000 reps
list(sliding_window (range(0, 1000), 32)) # 1.57s, 5000 reps
list(nwise (range(0, 1000), 64)) # 2.69s, 5000 reps
list(nwise_squashed (range(0, 1000), 64)) # 2.85s, 5000 reps
list(sliding_window (range(0, 1000), 64)) # 2.41s, 5000 reps
list(nwise (range(0, 1000), 128)) # 5.74s, 5000 reps
list(nwise_squashed (range(0, 1000), 128)) # 5.80s, 5000 reps
list(sliding_window (range(0, 1000), 128)) # 3.35s, 5000 reps
list(nwise (range(0, 1000), 256)) # 15.83s, 5000 reps
list(nwise_squashed (range(0, 1000), 256)) # 15.87s, 5000 reps
list(sliding_window (range(0, 1000), 256)) # 4.58s, 5000 reps
list(nwise (range(0, 100000), 1)) # 0.30s, 50 reps
list(nwise_squashed (range(0, 100000), 1)) # 0.30s, 50 reps
list(sliding_window (range(0, 100000), 1)) # 1.04s, 50 reps
list(nwise (range(0, 100000), 2)) # 0.34s, 50 reps
list(nwise_squashed (range(0, 100000), 2)) # 0.33s, 50 reps
list(sliding_window (range(0, 100000), 2)) # 1.05s, 50 reps
list(nwise (range(0, 100000), 4)) # 0.36s, 50 reps
list(nwise_squashed (range(0, 100000), 4)) # 0.37s, 50 reps
list(sliding_window (range(0, 100000), 4)) # 1.09s, 50 reps
list(nwise (range(0, 100000), 8)) # 0.44s, 50 reps
list(nwise_squashed (range(0, 100000), 8)) # 0.46s, 50 reps
list(sliding_window (range(0, 100000), 8)) # 1.22s, 50 reps
list(nwise (range(0, 100000), 16)) # 0.64s, 50 reps
list(nwise_squashed (range(0, 100000), 16)) # 0.64s, 50 reps
list(sliding_window (range(0, 100000), 16)) # 1.39s, 50 reps
list(nwise (range(0, 100000), 32)) # 1.13s, 50 reps
list(nwise_squashed (range(0, 100000), 32)) # 1.13s, 50 reps
list(sliding_window (range(0, 100000), 32)) # 1.83s, 50 reps
list(nwise (range(0, 100000), 64)) # 2.67s, 50 reps
list(nwise_squashed (range(0, 100000), 64)) # 2.64s, 50 reps
list(sliding_window (range(0, 100000), 64)) # 3.26s, 50 reps
list(nwise (range(0, 100000), 128)) # 4.47s, 50 reps
list(nwise_squashed (range(0, 100000), 128)) # 4.38s, 50 reps
list(sliding_window (range(0, 100000), 128)) # 4.88s, 50 reps
list(nwise (range(0, 100000), 256)) # 8.70s, 50 reps
list(nwise_squashed (range(0, 100000), 256)) # 8.57s, 50 reps
list(sliding_window (range(0, 100000), 256)) # 8.55s, 50 reps
Function most fast for a particular set of arguments:
[('nwise', 11), ('sliding_window', 6), ('nwise_squashed', 5)]
No comments:
Post a Comment