On Thu, Jun 17, 2021, 1:14 AM Christopher Barker > I'm sympathetic to raising an exception on `sum(list_of_lists)` similar to >> `sum(list_of_strings)`. But what exactly is the recommended substitute? >> We have this: >> >> list(chain.from_iterable(list_of_lists)) >> > > If you read the BPO the OP linked, that was a suggested patch to optimize > sum(list_of_lists) -- I'm not sure that's such a bad idea after all. >
The proposal was to drop in .__iadd__() for .__add__(), wasn't it? As a heavy NumPy user, you know those sometimes have different semantics. I actually showed that in my 7 year old talk as one argument against it. More-itertools has flatten(): https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.flatten. That seems better than a method specific to lists.
_______________________________________________ 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/7S7TNKTGY6SUE34GXB2QNIPQY3OQGXRE/ Code of Conduct: http://python.org/psf/codeofconduct/