On Thu, Jun 17, 2021 at 12:37 AM Serhiy Storchaka <storch...@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.
_______________________________________________
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/YH7COSZIV5BWQ3EOEA5MQMBHMB3OQNND/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to