◐ Shell
clean mode source ↗

Message 377478 - Python tracker

Timings depend on multiple factors, including implementation (cpython versus pypy versus cython, etc) and complexity of the keep/discard decision. I said in the proposed text that a listcomp may be faster.  I think that sufficient; anyone who cares can test their specific case.

I like the simple ad easy 'slice replacement = iterator' form because it illustrates to me that we have done something right with Python's design.