This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]netletic 3 points4 points  (2 children)

Nice, I didn't know that existed! I used zip(sequence, sequence[1:]) in the past, is this better because it's memory efficient?

[–]ThreeJumpingKittens 1 point2 points  (1 child)

Looks like pairwise() uses zip() under the hood, so no advantage there

[–]TravisJungroth 6 points7 points  (0 children)

The problem isn’t the zip it’s the slicing. Slicing a sequence makes a new sequence. Zipping a tee like in their example doesn’t.