On Wed, 30 Apr 2008 16:02:31 -0700, Guido van Rossum wrote: > There is one use case I can see for an iterator-version of os.listdir() > (to be named os.opendir()): when globbing a huge directory looking for a > certain pattern. Using os.listdir() you end up needed enough memory to > hold all of the names at once. Using os.opendir() you would need only > enough memory to hold all of the names THAT MATCH.
Not only that, but you can also start processing files one by one without having to wait for the whole list to be constructed (which might take time over a network file system); in fact, the user might even want to abort the operation after a few files were processed, in which case the whole directory is not accessed. -- Giovanni Bajo Develer S.r.l. http://www.develer.com _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com