On Thu, May 7, 2020 at 10:56 AM Alex Hall firstname.lastname@example.org wrote:
On Thu, May 7, 2020 at 9:48 AM Kirill Balunov email@example.com wrote:
Sorry for off topic. Isn't this chain.from_iterable just a historical legacy... now we have PEP 448 and I see no differences* between chain(*iterable) vs chain.from_iterable(iterable). Are there?
- chain.from_iterable is a little bit faster for small iterables, but if
at that time we had PEP 448, would this small speed benefits be enough to make additional method to chain. I think no.
`chain(*iterable)` converts iterable into a tuple, concretizing it in memory. chain.from_iterable(iterable) is lazy and goes through the elements one a time, meaning iterable can be infinite.
I don't think PEP 448 has any bearing on that.
Heh, surely, I misunderstood the point of PEP 448, and checked that it was also possible in Python 2.
"meaning iterable can be infinite" - thank you, I missed this part, but to be honest I don’t remember when I do something useful with infinite iterables.