Scanning through Directory

Anand Pillai pythonguy at Hotpop.com
Wed Aug 13 06:17:25 EDT 2003


Did you try os.path.walk() in your experiments?
If you did, you could post the profile data for it too.
I find it one of the most useful functions defined in
the os.path module.

Thanks!

Anand

"Michael Peuser" <mpeuser at web.de> wrote in message news:<bhalk1$qlv$06$1 at news.t-online.com>...
> There is a portable way of reading directories
>    os.listdir
> in conjunction with
>   os.stat and a little help from os.path.split and os.path.join
> Though using os.stat gives programs a somewhat clumbsy look,
> I had not been too annoyed with it until I tried to scan a whole disk.
> Reworking the join and split operations already gave a considerable
> speed-up
> 
> As I need it for Windows I then with very little effort changed to:
>    win32api.FindFiles
> (I already had used win32api.GetDiskFreeSpace)
> 
> This was a breakthrough: 5 secs instead of 50+ !
> 
> os.listdir seems to do little more than win32api FindFiles
> How can it be so slow???
> Why is there no portable way of getting "DiskFreeSpace" info
> Questions and Questions....
> 
> I strongly recommend the win32api calls it you have similar applications.
> The interface is extremely simple and the only penalty is non-compatibility
> ;-)
> 
> I also recommend to use the Python profiler from time to time for programms
> running more than one second. It might give you interesting insights...
> 
> Kindly
> Michael Peuser




More information about the Python-list mailing list