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

Random832 random832 at fastmail.us
Wed Nov 14 00:28:27 CET 2012


My very first post, and I screw up the reply to list option. Sorry about 
that.

On 11/13/2012 2:07 AM, Ronald Oussoren wrote:
> Where would st_mode be retrieved from?  The readdir(3) interface
> only provides d_type (and that field is not in POSIX or SUS).
>
> The d_type field contains a file type, and while you could use that
> to construct a value for st_mode that can be used to test the file
> type, you cannot reconstruct the file permissions from that.

I think he had the idea that it would just return this incomplete
st_mode, and you'd have to deal with it. But maybe the solution is to
add a st_type property to stat_result, that returns either this or the
appropriate bits from st_mode - is there a reason these are a single
field other than a historical artifact of the fact that they are/were in
a single 16-bit field in UNIX?

Note that according to the documentation not all filesystems on linux
support d_type, either. You have to be prepared for the possibility of
getting DT_UNKNOWN






More information about the Python-ideas mailing list