2 ms·
You can control the behavior manually, like: first = [0,1,2] second = [*a,3] # first is unchanged, second = [0,1,2,3] Or second=itertools.chain(first, [3]
by tyingq 5y ago
You can control the behavior manually, like:
first = [0,1,2]
second = [*a,3] # first is unchanged, second = [0,1,2,3]
Or second=itertools.chain(first, [3]), which avoids the copy.
Though, to me, it's asking for trouble later.
- deleted 5y ago[deleted]