2 ms·
Lists are mutable, tuples are not… that’s a massive difference if I’m editing code deep in a function I wrote two years ago.
by scoofy 10mo ago
Lists are mutable, tuples are not… that’s a massive difference if I’m editing code deep in a function I wrote two years ago.
- zahlman 10mo agoThe point is that you clearly aren't mutating it in the current context. Therefore, knowing that you could mutate it doesn't help you understand what the current code is doing, nor guide you away from mistakes (as you would have no reason to try to mutate it).
- scoofy 10mo agoI operate a site where I have lists of things that have operations done on them all the time, occasionally I’ll load those series into memory as a tuple to save memory. If I’m adding a feature to the site in 5 years, it’s going to be important to know if I’ve done that or not.