Alternative to os.listdir()/os.stat()
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:
> >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
> 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.
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
Size: 196 bytes
Desc: not available
More information about the Python-list