[Python-Dev] PEP 471 -- os.scandir() function -- a better and faster directory iterator

Glenn Linderman v+python at g.nevcal.com
Mon Jun 30 04:33:33 CEST 2014


On 6/29/2014 5:28 AM, Nick Coghlan wrote:
> There'd still be a slight window of discrepancy (since the filesystem
> state may change between reading the directory entry and making the
> lstat() call), but this could be effectively eliminated from the
> perspective of the Python code by making the result of the lstat()
> call authoritative for the whole DirEntry object.

+1 to this in particular, but this whole refresh of the semantics sounds 
better overall.

Finally, for the case where someone does want to keep the DirEntry 
around, a .refresh() API could rerun lstat() and update all the data.

And with that (initial data potentially always populated, or None, and 
an explicit refresh() API), the data could all be returned as 
properties, implying that they aren't fetching new data themselves, 
because they wouldn't be.

Glenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140629/dd20692a/attachment-0001.html>


More information about the Python-Dev mailing list