title: Why does python pickle load and dump inflate the size of of an object on disk?
body: <p>I have a pickled object in a file named b1.pkl:</p>
  
  <pre><code>$ ls -l b*
  -rw-r--r--  1 fireball  staff  64743950 Oct 11 15:32 b1.pkl
  </code></pre>
  
  <p>Then I run the following python code to load the object and dump it to a new file:</p>
  
  <pre><code>import numpy as np
  import cPickle as pkl
  
  fin = open('b1.pkl', 'r')
  fout = open('b2.pkl', 'w')
  
  x = pkl.load(fin)
  pkl.dump(x, fout)
  
  fin.close()
  fout.close()
  </code></pre>
  
  <p>The file this code creates is more than twice as large:</p>
  
  <pre><code>$ ls -l b*
  -rw-r--r--  1 fireball  staff   64743950 Oct 11 15:32 b1.pkl
  -rw-r--r--  1 fireball  staff  191763914 Oct 11 15:47 b2.pkl
  </code></pre>
  
  <p>Can anyone explain why the new file is so much larger than the original one? It should contain exactly the same structure.</p>