Scanning through Directory

Discussion in 'Python' started by Michael Peuser, Aug 12, 2003.

  1. 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
     
    Michael Peuser, Aug 12, 2003
    #1
    1. Advertising

  2. Michael Peuser

    Anand Pillai Guest

    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" <> wrote in message news:<bhalk1$qlv$06$-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
     
    Anand Pillai, Aug 13, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alan Searle

    Directory Scanning

    Alan Searle, Feb 18, 2006, in forum: XML
    Replies:
    10
    Views:
    676
    Joe Kesselman
    Mar 6, 2006
  2. Kun
    Replies:
    13
    Views:
    479
    Kent Johnson
    Apr 18, 2006
  3. Nazgob

    cross platform directory scanning

    Nazgob, Jul 31, 2005, in forum: C Programming
    Replies:
    4
    Views:
    520
    Alexei A. Frounze
    Jul 31, 2005
  4. Unknown Hero

    Scanning through Windows registry...

    Unknown Hero, May 6, 2008, in forum: Python
    Replies:
    16
    Views:
    1,044
  5. Dean
    Replies:
    2
    Views:
    386
    Grant Wagner
    Sep 12, 2003
Loading...

Share This Page