title: Pickle can't pickle a namedtuple
body: <p>I am trying to pickle the <code>namedtuple</code> like this:  </p>
  
  <pre><code>def f():
      TemplateData = namedtuple('TemplateData', ['field1', 'field2'])
      f1 = np.random.randn(50,50)
      f2 = np.random.randn(50,50)
      td = TemplateData(f1, f2)
      return td
  
  data = f()
  with open("aaaa.pkl", "wb") as fl:
      pkl.dump(data, fl)
  </code></pre>
  
  <p>but this crashes due to error:</p>
  
  <pre class="lang-none prettyprint-override"><code>PicklingError: Can't pickle &lt;class '__main__.TemplateData'&gt;: it's not the same object as __main__.TemplateData
  </code></pre>
  
  <p>What's wrong?
  If <code>pickle</code> is not the best way to store named tuple - what is the most efficient way?</p>