Opinion on best practice...

Peter Otten __peter__ at web.de
Tue Feb 5 11:35:19 CET 2013


Ulrich Eckhardt wrote:

> separate variable but iterated over it directly. For large dirs, it
> could also be better to use os.path.walk(), because that doesn't first
> build a list and then iterate over the list but iterates over the single
> elements directly. This avoids the memory allocation overhead, although
> it is unlikely to make a difference in this case and a Premature
> Optimization(tm).

Not true. os.walk() uses os.listdir() internally.




More information about the Python-list mailing list