title: Returning self.__dict__ from a method
body: <p>I am working with a nice little python module from a third party, and I ran across a bit that has got my brain all twisted, and I'm mostly concerned with data integrity.</p>
  
  <p>Quick summary: there is a class method that goes roughly as such:</p>
  
  <pre><code>def as_dict(self):
      ##adjust some attributes that don't make sense outside this scope        
      ##... ... ...
      return self.__dict__
  </code></pre>
  
  <p>I am manually using the result of this method, but there are a few places where I pass it on, and I have no idea what those function are actually doing to the returned dict.</p>
  
  <p>Now, is this safe as it is, or could some stray function start messing with my instance attributes? I originally thought that 'self' somehow protected the dataset, and I was passing around a copies of the data, but now I wonder if I am passing around references to instance memory? (there are nested mutables within)</p>
  
  <p>Should I just do instead: <code>return copy.deepcopy(self.__dict__)</code></p>