#python #datastructure #efficiency
-
Both
dict
andset
use braces{}
to initialize comprehension- The difference on what will be the final result depends on which is provide inside braces
-
Generation expression does not initialize a list, in that case saves more memory
- Used with tuples and other type of sequences (array.array for example)
- One element is treated per time
-
On
array.array
for generation expression you can pass the type of the natural number. -
List comprehension are faster than
genexp
, but can only save the result asList
, whilegenexp
can save in any iterable type.