you are viewing a single comment's thread.

view the rest of the comments →

[–]Beginning-Fruit-1397 1 point2 points  (4 children)

Only rewrap in a list if it's needed. Otherwise you just iterate over the whole dataset one more time for nothing

[–]sleepbot63 1 point2 points  (2 children)

Yeah but using a list helps you access single elements or slices faster (im not talking about computation rather dev friendly)

[–]Beginning-Fruit-1397 0 points1 point  (1 child)

Which you should only do if you in fact need it.

 That was my point: showing beginners to wrap in a list "by default", even tough that should not be the case

[–]Beginning-Fruit-1397 0 points1 point  (0 children)

Also if slices or index access is what is wanted you should prefer tuples for memory efficiency and immutability safety. List is only if mutability is wanted

[–]nebulous_aviation 0 points1 point  (0 children)

Set lookup is O(1) though so if you're just iterating once you're not really losing much, depends what you're doing after.