The first can only handle unpacked iterations. The latter can handle iterations that cannot be completely unpacked, for example, infinite generators.
Consider
>>> from itertools import chain >>> def inf(): ... i=0 ... while True: ... i += 1 ... yield i ... >>> x=inf() >>> y=chain.from_iterable(x) >>> z=chain(*x) <hangs forever>
In addition, only the act of unpacking is impatient activity before starting work, so if your iterative effect has an effect that you want to evaluate lazily, from_iterable is your best option.
kojiro
source share