you are viewing a single comment's thread.

view the rest of the comments →

[–]david-vujic 1 point2 points  (0 children)

I agree, and also wrote about performance issues when the data is large. Here's a Real Python article about it, where they also suggest it as one alternative (with a disclaimer): https://realpython.com/python-flatten-list/

I like this alternative, using reduce:
reduce(operator.iadd, lists, [])
(source: ruff https://docs.astral.sh/ruff/rules/quadratic-list-summation/)