Message362888
I think a tuple comprehension could be very useful.
Currently, the only way to efficiently create a tuple from a comprehension is to create a list comprehension (generator comprehensions are more slow) and convert it with `tuple()`.
A tuple comprehension will do exactly the same thing, but without the creation of the intermediate list.
IMHO a tuple comprehension can be very useful, because:
1. there are many cases in which you create a list with a comprehension, but you'll never change it later. You could simply convert it with `tuple()`, but it will require more time
2. tuples uses less memory than lists
3. tuples can be interned
As syntax, I propose
(* expr for x in iterable *)
with absolutely no blank character between the character ( and the *, and the same for ).
Well, I know, it's a bit strange syntax... but () are already taken by generator comprehensions. Furthermore, the * remembers a snowflake, and tuples are a sort of "frozenlists". |
|
Date |
User |
Action |
Args |
2020-02-28 17:44:14 | Marco Sulla | set | recipients:
+ Marco Sulla |
2020-02-28 17:44:14 | Marco Sulla | set | messageid: <1582911854.61.0.127481778131.issue39784@roundup.psfhosted.org> |
2020-02-28 17:44:14 | Marco Sulla | link | issue39784 messages |
2020-02-28 17:44:14 | Marco Sulla | create | |
|