Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 554 Bytes

0651-genexp.md

File metadata and controls

18 lines (14 loc) · 554 Bytes

genexp

#programming #language #python #functional

  • Save more memory comparable to [[ndtq-listcomp]]
  • Can be used with [[82os-python-tuples]], arrays and other sequences
  • Save the cost to build a [[aw9b-python-list]]
  • The result can be saved as list, tuple, or dictionary
>>> symbols
>>> tuple (ord(symbol) for symbol in symbols)
(36, 162, 163, 165, 8364, 164)

>>> import array
>>> array.array ('I', (ord(symbol) for symbol in symbols))