3 ms·
No! Never do this in Python. You are making the flattened list by continually concatenating the smaller lists. Each concatenation creates the new bigger list f
by 00ajcr 10y ago
No! Never do this in Python.
You are making the flattened list by continually concatenating the smaller lists. Each concatenation creates the new bigger list from scratch; the flattened list does not grow dynamically. This is quadratic-performance bad.
Use `list(itertools.chain.from_iterable(...))` instead.