title: (locally) cached file object in Python
body: <p>I'm often working with large data files which I need to access over the network (mostly via NFS, but sometimes also via CIFS). For performance reasons it would be good to cache these files on the local harddrive to minimize network use.</p>
  
  <p>So basically I'm looking for a file-object which automatically takes care of the local caching, something along these lines:</p>
  
  <pre><code>import CachedFileObject as cfo
  cfo.set_local_cache_dir("/tmp")
  handle = cfo.open("/nfs/server1/bigdatafile.nc", "r") # copy file to /tmp, open the copy
  # do stuff with the filehandle
  del handle                                            # delete the local copy
  </code></pre>
  
  <p>I really only need this for <strong>reading</strong> files. If there should be an easy way to also get/implement file creation (or even writing), that would be a bonus.</p>
  
  <p>Any ideas are greatly appreciated</p>