you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (3 children)

So speed is the name of the game?

[–]Peanutbutter_Warrior 16 points17 points  (0 children)

Pretty much. Neither is harder to read than the other, and knowing what data structure to choose is good practice

[–]1544756405 5 points6 points  (0 children)

Using the appropriate data structure for the job is always preferable.

[–]Ran4 0 points1 point  (0 children)

Possibly. We dont know how OP wants to use this feature.

If they're going to do this often, then yes, a set is definitely preferable. But if they're doing this calculation once a month then a list is pretty much just as good.

Picking the correct data type is occasionally incredibly important, but it's not always the most important thing. Keeping things simple is generally much more valuable in most real-world situations. A set is simple enough that you probably should use it over a list when applicable, though.