News for hackers. Stuff that matters.
Re:Copying data is wasteful, mutating data is dangerous by jszymborski on Thursday January 09, 2020 @02:46PM (#22004835)
in-place operations give me the heebie-jeebies.

I think this is something that is a slightly less obvious when dealing with classes. I see stuff like this in academic code all the time:

  class SomeDataObj:
    def __init__(self, data):
      self.data = data
    
    def normalize(self):
      self.data = normalize(self.data)
I'd much prefer for there to be variable `self.data_normalized` which is initialized to None or even better a getter `getNormalizedData()` that computes/caches a normalized variable.
Re:Copying data is wasteful, mutating data is dangerous by UncleEntity on Thursday January 09, 2020 @04:55PM (#22006334)
The pythonic way would be to have sort() and sorted() which either sort in place or return a sorted copy. Best of both worlds.
Re:Copying data is wasteful, mutating data is dangerous by ajuc on Thursday January 09, 2020 @07:01PM (#22007211)
Command Query Separation is a very good general idea in programming that should be followed more often. Sadly it went out of fashion in 90s when everybody got hyped about OOP.