title: Store/retrieve a data structure
body: <p>I have implemented a <strong>suffix tree</strong> in Python to make full-text-searchs, and it's working really well. But there's a problem: the indexed text can be very big, so we won't be able to have the whole structure in RAM.</p>
  
  <p><img src="https://i.stack.imgur.com/qwBlG.gif" alt="enter image description here"></p>
  
  <p><strong>IMAGE:</strong> Suffix tree for the word <code>BANANAS</code> (in my scenario, imagine a tree 100000 times bigger).</p>
  
  <p>So, researching a little bit about it I found the <code>pickle</code> module, a great Python module for "loading" and "dumping" objects from/into files, and guess what? It works wonderfully with my data structure.</p>
  
  <p>So, making the long story shorter: What would be the best strategy to store and retrieve this structure on/from disk? I mean, a solution could be to store each node in a file and load it from disk whenever is needed, but this isn't the best think to do (too many disk accesses).</p>
  
  <hr>
  
  <p><strong>Footnote:</strong> Although I have tagged this question as <a href="/questions/tagged/python" class="post-tag" title="show questions tagged &#39;python&#39;" rel="tag">python</a>, the programming language isn't the important part of the question, the disk storing/retrieving strategy is really the main point.</p>