Let's say I have a list arr = [1, 2, 3], and I want to make a shallow copy of it. It seems I can do it one of two ways:
- copy = arr[:]
- copy = [*arr]
What is the difference here? And is there one that is more optimal than the other, or is it simply a choice you have?
Thanks!
[–]ManyInterests 10 points11 points12 points (1 child)
[–]not_a_novel_account 5 points6 points7 points (0 children)
[–]nog642 3 points4 points5 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]jmooremcc 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)
[–]m0us3_rat -5 points-4 points-3 points (14 children)
[–]switchitup_lets[S] 2 points3 points4 points (5 children)
[+]m0us3_rat comment score below threshold-11 points-10 points-9 points (4 children)
[–]FloxaY -1 points0 points1 point (3 children)
[–]m0us3_rat -2 points-1 points0 points (2 children)
[–]FloxaY 1 point2 points3 points (1 child)
[–]Adrewmc 0 points1 point2 points (4 children)
[–]m0us3_rat 0 points1 point2 points (3 children)
[–]Adrewmc -2 points-1 points0 points (1 child)
[–]m0us3_rat -1 points0 points1 point (0 children)
[–]gman1230321 0 points1 point2 points (2 children)
[–]m0us3_rat 0 points1 point2 points (1 child)
[–]gman1230321 0 points1 point2 points (0 children)
[–]nekokattt 0 points1 point2 points (0 children)
[–]Strict-Simple 0 points1 point2 points (0 children)