So I want to iterate over pairs of subsequent elements. The "pythonic" (I hope at least) way to do it would be:
# `a` is a list of something
for elem_1, elem_2 in zip(a, a[1:]):
...
The less pythonic way would probably be something like
for i in range(len(a) - 1):
elem_1 = a[i]
elem_2 = a[i + 1]
# yikes, so much indexing
...
I like how the option 1 looks, but I'm not sure whether this sneaky a[1:]
will create a copy of the a
list and thus use twice as much memory. Will it? Will it not?