[Python-3000] Removal of os.path.walk
John Barham
jbarham at gmail.com
Wed Apr 30 09:42:00 CEST 2008
On Tue, Apr 29, 2008 at 8:42 PM, Guido van Rossum <guido at python.org> wrote:
> On Tue, Apr 29, 2008 at 8:10 PM, Tim Heaney <theaney at gmail.com> wrote:
> > Speaking of this, is it too late to lobby for an iterator version of
> > os.listdir? (Perhaps listdir would not be the best name. :)
> >
> > There is one at
> >
> > http://wxidle.sourceforge.net/projects/xlistdir/
> >
> > but I think it ought to be in the standard library. Moreover, if we
> > had such a thing, shouldn't os.walk use it instead of lists?
>
> I'm not sure I see the advantage of having it as an iterator; I doubt
> that there is ever not enough memory to hold the contents of a single
> directory. Do you have a compelling use case?
I don't know how compelling it is, but the dirread Plan 9 call to get
a directory listing
(http://plan9.bell-labs.com/magic/man2html/2/dirread) returns only a
subset of the entries in the directory so it effectively acts as an
iterator. If it's listing a network shared file system an iterator
version of listdir could result in less network traffic depending on
what entry you were looking for. I don't know if NFS is the same but
I think in general it would be a win for network file systems in terms
of efficiency.
John
More information about the Python-3000
mailing list