title: How to speed up python starting up and/or reduce file search while loading libraries?
body: <p>I have a framework composed of different tools written in python in a multi-user environment.</p>
  
  <p>The first time I log to the system and start one command it takes 6 seconds just to show a few line of help. If I immediately issue the same command again it takes 0.1s. After a couple of minutes it gets back to 6s. (proof of short-lived cache)</p>
  
  <p>The system sits on a GPFS so disk throughput should be ok, though access might be low because of the amount of files in the system.</p>
  
  <pre><code>strace -e open python tool | wc -l
  </code></pre>
  
  <p>shows 2154 files being accessed when starting the tool.</p>
  
  <pre><code>strace -e open python tool | grep ENOENT | wc -l
  </code></pre>
  
  <p>shows 1945 missing files being looked for. (A very bad hit/miss ratio is you ask me :-)</p>
  
  <p>I have a hunch that the excessive time involved in loading the tool is consumed by querying the GPFS about all those files, and these are cached for the next call (at either system or GPFS level), though I don't know how to test/prove it.
  I have no root access to the system and I can only write to GPFS and /tmp.</p>
  
  <p>Is it possible to improve this <code>python quest for missing files</code>?</p>
  
  <p>Any idea on how to test this in a simple way?
  (Reinstalling everything on /tmp is not simple, as there are many packages involved, virtualenv will not help either (I think), since it's just linking the files on the gpfs system).</p>
  
  <p>An option would be of course to have a daemon that forks, but that's far from "simple" and would be a last resort solution.</p>
  
  <p>Thanks for reading.</p>