title: How to store the result of an executed function and re-use later?
body: <p>E.g., I have:</p>
  
  <pre><code>def readDb():
      # Fetch a lot of data from db, spends a lot time
      ...
      return aList
  
  def calculation():
      x = readdb()
      # Process x
      ...
      return y
  </code></pre>
  
  <p>In the python interpreter,<br>
  each time I run <code>calculation()</code> it takes a lot of time to re-read the database, which is unnecessary.<br>
  How can I store the result from <code>readdb()</code> to avoid this reducdant process?</p>
  
  <p><strong>Edit:</strong><br>
  I found a similar question here but I don't quite know the answer<br>
  <a href="https://stackoverflow.com/questions/10230869/">Save functions for re-using without re-execution</a></p>