By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,374 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

fast listdir & stat

P: n/a
I want to get the files and sizes and times etc. stats of a dir fast.
os.listdir & iterating with os.stat seems not to run at optimal speed for network folders. Is there a faster possibility? (both for Win & *nix ; best platform independent)
Robert
Nov 24 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

robert wrote:
I want to get the files and sizes and times etc. stats of a dir fast.
os.listdir & iterating with os.stat seems not to run at optimal speed for network folders. Is there a faster possibility? (both for Win & *nix ; best platform independent)
Robert
An alternative is to work with os.walk() it returns a generator - see
http://docs.python.org/lib/lib.html, and os.path.getsize(),
os.path.gettmtime() - see http://docs.python.org/lib/module-os.path.html

Nov 24 '06 #2

P: n/a
wi******@hotmail.com wrote:
robert wrote:
>I want to get the files and sizes and times etc. stats of a dir fast.
os.listdir & iterating with os.stat seems not to run at optimal speed for network folders. Is there a faster possibility? (both for Win & *nix ; best platform independent)

An alternative is to work with os.walk() it returns a generator - see
http://docs.python.org/lib/lib.html, and os.path.getsize(),
os.path.gettmtime() - see http://docs.python.org/lib/module-os.path.html
would be even slower - 2 or 3 (network) calls for each file. os.walk just uses listdir.

Robert
Nov 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.