`itertools.all_equal`

Well don’t ignore the context, i.e., what I replied to. You said “Is this for statement […]” and I told you it isn’t one and what it actually is, so you can look it up if you want to.

And nowhere did I say you have.

Because that’s your code and when iterable is a list, then both the iterable[1:] and the iterable[:-1] make a copy of the entire list minus one element, both taking linear space.