◐ Shell
clean mode source ↗

Message 377484 - Python tracker

> 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.

I understand that you like it and that it reflects the way you think the world should work, , but that doesn't warrant putting it in the FAQ.  We should steer users down a path of feeding unsizable inputs into tooling that needs a size to work well (the receiving code either has to implicitly build a list first before it can start or it will have to have periodic resizes). A straight list comprehension will suffice to answer the question cleanly.

FWIW, the same issue occurs with str.join().  It works better with a list comprehension than an iterator.  Given an iterator, it has to build an internal list first before it can start.  That is slower than starting with a list in the first place and makes the memory consumption implicit when it should be explicit (a generator would create the illusion that a list isn't being formed which is misleading).