On 29.06.2014 13:08, Nick Coghlan wrote:
On 29 June 2014 20:52, Steven D'Aprano firstname.lastname@example.org wrote:
Speaking of caching, is there a way to freshen the cached values?
Switch to a full Path object instead of relying on the cached DirEntry data.
This is what makes me wary of including lstat, even though Windows offers it without the extra stat call. Caching behaviour is *really* hard to make intuitive, especially when it *sometimes* returns data that looks fresh (as it on first call on POSIX systems).
This bugs me too. An idea I had was adding a keyword argument to scandir which specifies whether stat data should be added to the direntry or not.
If the flag is set to True, This would implicitly call lstat on POSIX before returning the DirEntry, and use the available data on Windows.
If the flag is set to False, all the fields in the DirEntry will be None, for consistency, even on Windows.
This is not optimal in cases where the stat information is needed only for some of the DirEntry objects, but would also reduce the required logic in the DirEntry object.