News for hackers. Stuff that matters.
Re:Copying data is wasteful, mutating data is dangerous by capableweb on Thursday January 09, 2020 @02:19PM (#22004481)
Seems like "both libraries make copies of the data, which means you’re using even more RAM." is a assumption (that copy data leads to more RAM usage) and I'm guessing the libraries (haven't used them myself, nor python, so not sure how feasible this is) can be implemented like a persistent data structure (https://en.wikipedia.org/wiki/Persistent_data_structure) and therefore get both immutability (which leads to less bugs, no mutability) and not that high RAM usage. Clojure is a famous example of something that implements persistent data structures.
Re:Copying data is wasteful, mutating data is dangerous by perfunctory on Thursday January 09, 2020 @02:28PM (#22004603)
> can be implemented like a persistent data structure

you don't get much benefit from persistent structures if every element of an array is modified, like in the examples in the post.

Re:Copying data is wasteful, mutating data is dangerous by pipeep on Thursday January 09, 2020 @05:27PM (#22006572)
If the data structure has a reference count of one, you can safely mutate the data structure instead. Many persistent immutable data structure libraries use this as an additional optimization.
Re:Copying data is wasteful, mutating data is dangerous by capableweb on Thursday January 09, 2020 @02:31PM (#22004635)
I missed that, sorry. Thanks for clarifying!