On Tue, Dec 1, 2020 at 5:43 PM Paul Sokolovsky firstname.lastname@example.org wrote:
That's in the eye of the beholder, I'm afraid. So, if you don't want to be convinced of those clarity improvements, you'll never be.
It's hard to be convinced by something that neither you nor anyone else on the thread has actually presented.
It's not especially common, but I've sometimes written:
for i in big_collection: if condition(): break # other stuff ... intervening code ... if i+1 < len(big_collection): something_about_early_stop()
On the other hand, I can count on one hand, without using any fingers, the number of times when I would have used:
for const i in big_collection: # whatever
It's just not a need that arises.
There exist TWO highly successful, widely used, JIT compilers for Python. PyPy and Numba. Neither one of them would have any use whatsoever for this constantness. Or if you believe otherwise, get a developer of one of those to comment so. JIT'd Python simply is not slow, even compared to compiled languages. Searching for maybe-possibly-someday optimizations while ignoring the actual speed paths, is silly.