Alternative to os.listdir()/os.stat()

Jp Calderone exarkun at intarweb.us
Fri Jan 24 06:06:53 CET 2003


On Thu, Jan 23, 2003 at 08:15:04PM -0800, Tim Roberts wrote:
> [snip]
> 
> >However, I noticed that this approach takes a long time when the
> >directory contains lots of files. So what I am looking for now is a
> >function that can give me the details is one go, much like 'ls -ltra' in
> >UNIX. 
> 
> You realize, of course that "ls -ltra" does exactly what your loop does?
> The only difference is that it's in C.

  Not -exactly- the same thing.  ls has the advantage of having access
opendir() and readdir(), which are significantly faster than repeated calls
to stat.  Hopefully a future version of posixpath.c will provide access to
these for us poor Python programmers.

  Jp

-- 
http://catandgirl.com/view.cgi?90
-- 
 up 39 days, 9:49, 4 users, load average: 0.50, 0.48, 0.45
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030124/3af07bf6/attachment.pgp>


More information about the Python-list mailing list