title: Is `pickle.dump(d, f)` equivalent to `f.write(pickle.dumps(d))`?
body: <p>Given an arbitrary picklable Python data structure <code>data</code>, is</p>
  
  <pre><code>with open('a', 'bw') as f:
      f.write(pickle.dumps(data))
  </code></pre>
  
  <p>equivalent to </p>
  
  <pre><code>with open('a', 'bw') as f:
      pickle.dump(data, f)
  </code></pre>
  
  <p>i.e. can I assume this equivalence when writing code? Could you describe how you reached to this conclusion?</p>
  
  <p>The use-case is to separate serialization from writing, since I may want to write pickle to a non-disk location.</p>