Re:Why is Common Lisp not the most popular programming langu...
by thaumasiotes on Wednesday February 14, 2024 @07:32PM
(#39377586)
> If you want shared structure of lists in Python, use `itertools.chain`.
That would involve zero shared structure. itertools.chain is just an iterator that iterates one iterable and then, instead of declaring that it's done, goes on to iterate another one.
Shared structure between lists means that two lists refer to some of the same regions of memory.
Re:Why is Common Lisp not the most popular programming langu...
by o11c on Wednesday February 14, 2024 @08:49PM
(#39378176)
And multiple `itertools.chain` instances pointing to the same list chunk(s) also use sharing.
Re:Why is Common Lisp not the most popular programming langu...
by thaumasiotes on Wednesday February 14, 2024 @10:31PM
(#39378785)
OK, that is true, but that approach would have the significant downside that you can't pass over a list more than once.
If you want shared structure of lists in Python, use `itertools.chain`.
If you want key-value mappings, use a dict. Order is preserved by default nowadays, and conversion to/from an iterable of 2-tuples is trivial.