title: unable to pickle scipy.spatial.KDTree objects
body: <p>I have a code where I build a huge tree and I need to save it for later use.
  Unluckily it seems I cannot pickle <code>scipy.spatial.KDTree</code> objects.</p>
  
  <p>In fact, when I run this:</p>
  
  <pre><code>import pickle
  import scipy.spatial
  tree=scipy.spatial.KDTree([[1,2,3]])
  pickle.dump(tree,open('tree.p','wb'))
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib64/python2.7/pickle.py", line 1370, in dump
      Pickler(file, protocol).dump(obj)
    File "/usr/lib64/python2.7/pickle.py", line 224, in dump
      self.save(obj)
    File "/usr/lib64/python2.7/pickle.py", line 331, in save
      self.save_reduce(obj=obj, *rv)
    File "/usr/lib64/python2.7/pickle.py", line 419, in save_reduce
      save(state)
    File "/usr/lib64/python2.7/pickle.py", line 286, in save
      f(self, obj) # Call unbound method with explicit self
    File "/usr/lib64/python2.7/pickle.py", line 649, in save_dict
      self._batch_setitems(obj.iteritems())
    File "/usr/lib64/python2.7/pickle.py", line 663, in _batch_setitems
      save(v)
    File "/usr/lib64/python2.7/pickle.py", line 331, in save
      self.save_reduce(obj=obj, *rv)
    File "/usr/lib64/python2.7/pickle.py", line 401, in save_reduce
      save(args)
    File "/usr/lib64/python2.7/pickle.py", line 286, in save
      f(self, obj) # Call unbound method with explicit self
    File "/usr/lib64/python2.7/pickle.py", line 562, in save_tuple
      save(element)
    File "/usr/lib64/python2.7/pickle.py", line 286, in save
      f(self, obj) # Call unbound method with explicit self
    File "/usr/lib64/python2.7/pickle.py", line 748, in save_global
      (obj, module, name))     pickle.PicklingError: Can't pickle &lt;class 'scipy.spatial.kdtree.leafnode'&gt;: it's not found as scipy.spatial.kdtree.leafnode
  </code></pre>
  
  <p>Given this, is there a way to pickle it?  or at least to save a part of the object that can be used to rebuild the tree fastly? Otherwise,  are there other fast options besides  scipy.spatial.KDTree?</p>