Alternative to os.listdir()/os.stat()
donn at drizzle.com
Fri Jan 24 07:30:44 CET 2003
Quoth Jp Calderone <exarkun at intarweb.us>:
| On Thu, Jan 23, 2003 at 08:15:04PM -0800, Tim Roberts wrote:
|> 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.
I doubt it! It's certainly possible that ls as implemented on a
specific platform may be able to get all that information without
calling stat. But if you think POSIX 1003.1 readdir can do anything
like that - it would be interesting to see how, maybe I'm missing
Donn Cave, donn at drizzle.com
More information about the Python-list