Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Scanning through Directory

Reply
Thread Tools

Scanning through Directory

 
 
Michael Peuser
Guest
Posts: n/a
 
      08-12-2003
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






 
Reply With Quote
 
 
 
 
Anand Pillai
Guest
Posts: n/a
 
      08-13-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" <(E-Mail Removed)> wrote in message news:<bhalk1$qlv$06$(E-Mail Removed)-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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scanning through Windows registry... Unknown Hero Python 16 05-16-2008 08:56 PM
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
scanning through page and replacing all instances of 00:00:00.00 Kun Python 13 04-18-2006 10:10 AM
Directory Scanning Alan Searle XML 10 03-06-2006 02:47 AM
cross platform directory scanning Nazgob C Programming 4 07-31-2005 03:46 PM



Advertisments