File Polling (Rereading)

Peter Hansen peter at engcorp.com
Thu Oct 21 11:14:38 EDT 2004


Daniel Mueller wrote:
> hmm i'll have to rephrase my question... i KNOW that the file changes 
> every 10 seconds... easiest would be i just give you the source code ;)
> the program is a nice little windows which displays ACPI information 
> about battery status and stuff like that. the program is working just 
> fine. 

What makes you think there is any way to detect the file changes
or read only the changes from files in the /proc file system?

Looking briefly at /proc on my own (non-laptop, so no acpi folder)
machine, I see that the dates as shown by "ls -l" or os.stat()
are *always* the current time... they increment second-by-second
as I run os.stat() repeatedly.

 > but i want the performance tweak it...

Why?  Do you have any evidence that you have a performance problem
related to reading the data from these pseudo-files?  (I'm guessing
that you think they are real files on your hard drive, but even
if that were the case, you probably haven't measured the access
or read times to prove that you actually *have* a problem.)

/proc is a *virtual* file system, so reading data from it is
about as fast as transferring bytes around in memory (to a
first approximation, anyway).  Measure it!

If you don't have evidence of poor performance, you are probably
doing "premature optimization".

-Peter



More information about the Python-list mailing list