Optimizing tips for os.listdir
Jaco Smuts
JSmuts at clover.co.za
Mon Sep 27 06:51:54 EDT 2004
I have not tested the speed on this, but I use the os.walk module for
similair functionality.
Thomas <2002 at weholt.org>
Sent by: python-list-bounces+jsmuts=clover.co.za at python.org
09/27/2004 12:44 PM
To: python-list at python.org
cc:
Subject: Optimizing tips for os.listdir
I'm doing this :
[os.path.join(path, p) for p in os.listdir(path) if \
os.path.isdir(os.path.join(path, p))]
to get a list of folders in a given directory, skipping all plain
files. When used on folders with lots of files, it takes rather long
time to finish. Just doing a listdir, filtering out all plain files
and a couple of joins, I didn't think this would take so long.
Is there a faster way of doing stuff like this?
Best regards,
Thomas
--
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040927/4ece9c95/attachment.html>
More information about the Python-list
mailing list