[Python-ideas] Speed up os.walk() 5x to 9x by using file attributes from FindFirst/NextFile() and readdir()
Mike Meyer
mwm at mired.org
Thu Nov 15 07:09:41 CET 2012
On Wed, Nov 14, 2012 at 11:53 PM, Jim Jewett <jimjjewett at gmail.com> wrote:
> On 11/15/12, Mike Meyer <mwm at mired.org> wrote:
>> On Nov 14, 2012 10:19 PM, "Jim Jewett" <jimjjewett at gmail.com> wrote:
>> I want to distinguish between the case where st_mode is filled from the
>> BSD/Unix d_type directory entry - meaning there is information so st_mode
>> is not None, but the information is incomplete and requires a second system
>> call to fetch - and the case where it's filled via the Windows calls which
>> provide all the information that is available for st_mode, so no second
>> system call is needed.
> So you're basically saying that you want to know whether an explicit
> stat call would make a difference? (Other than updating the
> information if it has changed.)
That's one way of looking at it. The problem is that you tell if a
value has been filled or not by having a None value. But st_mode is
itself multi-valued, and you don't always get all available
value. Maybe d_type should be it's own attribute? If readdir returns
it, we use it as is. If not, then the caller either does the None/stat
dance or we make it a property that gets filled from the stat
structure.
Thanks,
<mike
More information about the Python-ideas
mailing list