[Python-ideas] Speed up os.walk() 5x to 9x by using file attributes from FindFirst/NextFile() and readdir()

Serhiy Storchaka storchaka at gmail.com
Fri Nov 9 15:54:44 CET 2012


On 09.11.12 16:42, Christian Heimes wrote:
> +1 for something like yielddir().

See also http://bugs.python.org/issue11406.

> I while ago I proposed that the os module shall get another function for
> iterating over a directory. The new function is to return a generator
> that yields structs. The structs contain the name and additional
> metadata that like the d_type. On Unix it should use the reentrant
> version of readdir(), too.

The only fields in the dirent structure that are mandated by POSIX.1 are: d_name[], of unspecified size, with at most NAME_MAX characters preceding the terminating null byte; and (as an XSI extension) d_ino. The other fields are unstandardized, and not present on all systems.





More information about the Python-ideas mailing list