On Thu, May 7, 2020 at 10:56 AM Alex Hall <alex.moj...@gmail.com> wrote:
> On Thu, May 7, 2020 at 9:48 AM Kirill Balunov <kirillbalu...@gmail.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. >> >> -gdg >> > > `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. -gdg
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EC3XT7CUC5EZ2DGC24DLTKFOGCLJQH5A/ Code of Conduct: http://python.org/psf/codeofconduct/