views:

121

answers:

3

I am starting to use python,more. Is there a good way to keep python disk access to a minimum.

Seems to me that everytime a *.py file runs, it hits a hard disk. Is there way to avoid hitting the harddisk, and keep *.py file in memory and access it there.

Would creating a small gui using Wxframe, keep code in memory, and reuse work or is it more pain vs benefit.

+2  A: 

If you run a .py file from the harddisk, the harddisk will be accessed.

In your GUI, just import your code and it will be loaded once and you can access it later.

leoluk
Thats what I was thinking, would the size wptyhon be large or small. How would check which pthyon.exe is running one gui vs another?
I don't understand your question
leoluk
Im using windows.... task manager sees pythonw.exe running, there are 3-4 running, which one is gui? which one is SciTE
I still don't understand your question; SciTE?
leoluk
On windows, Every times python runs, it launches an instances of pythonw.exe. When one app is running, there is only one pythonw.exe. But, when 3or4 apps are running the task manager shows 3 or4 pythonw.exe running with different memory levels. How Do I ID the pythonw.exe's and associated them with the app to see memory usage.
A: 

I think if you took the time to measure how much time it takes to load your python code from disk you would end up with a very, very tiny number unless you are doing something very wrong. And if you are doing something really wrong, solving that problem will be a better use of your time.

Using wxpython to create a guy to work around what you perceive to be a problem wouldn't likely make any difference.

Bryan Oakley
+1  A: 

Modern operating systems cache file access pretty efficiently, as long as there is enough spare RAM available. You most likely won't notice any difference, fi you're not loading thousand of python files at once.

And as always, before trying to optimize one aspect, make sure that this is really the bottleneck. Chances are, your percieved slowness is not due to loading of the .py files.

Fabian