On Thu, Jun 17, 2021 at 12:37 AM Serhiy Storchaka <storchaka@gmail.com> wrote:
And it is equivalent to pure Python code

    [x for chunk in list_of_lists for x in chunk]

Okay, slightly off-topic, but can we *please* allow

    [*chunk for chunk in list_of_lists]

some day. I think it was left out because some discussion concluded it would be too confusing, which is ridiculous. I assumed it would work and was confused to find that it didn't. It's blatantly inconsistent.

It's not even the performance I care about, it's the unreadability of having an extra "for i_have_to_think_of_yet_another_variable_name in whatever" at the end of the list comprehension (at maximum distance from where the variable is used). I've wished for this feature ridiculously many times.
 
It would be
possible to make the compiler recognizing such pattern and generating
more efficient bytecode (LIST_EXTEND instead of an internal loop with
LIST_APPEND), but I am not sure that this case is common enough to
complicate the compiler.

In my personal experience it's very common.