4 ms·
> Where did you get immutable data structures from in Python Here's my favored source (in the Standard Library) https://docs.python.org/2/library/collections.h
by devishard 10y ago
> Where did you get immutable data structures from in Python
Here's my favored source (in the Standard Library) https://docs.python.org/2/library/collections.html#collections.namedtuple https://docs.python.org/2/library/collections.html#collectio...
> and what do you do when every third party library you interact with uses mutable ones?
That's situational; which library are you having a problem with? I haven't really had that problem (okay, sometimes the tooling around web frameworks do stupid things, but that's not common).
Note that just because something is mutable doesn't mean you have to mutate it. Yes, Python doesn't as widely enforce non-mutation as Haskell, OCaml, etc., but that doesn't mean that suddenly all the Python programmers lost their minds and started mutating all the things. We're not savages.
- tome 10y ago> Note that just because something is mutable doesn't mean you have to mutate it I agree, and I don't mutate it, but my third party libraries and my collegues functions will. Not all of them, but enough to introduce annoying bugs.
- devishard 10y agoThis is why I asked, "Which library are you having a problem with?" You've claimed that third party libraries and your colleague's functions will mutate the data structures you pass them, but this has very rarely been my experience.