-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
I propose we add a new Path.status attribute that stores an os.DirEntry object in paths yielded from Path.iterdir(), or a pathlib-specific type with a similar interface in other paths.
This would:
- Allow users to access to the cached
os.DirEntryafter callingPath.iterdir(), which is useful for efficiently determining files' types and often doesn't involve a system call. - Allow users to switch on the type of any path without repeatedly making system calls, or having to resort to
S_ISREG(st.st_mode)and other holy incantations. - In the pathlib ABCs, allows us to entirely banish
PathBase.stat()and thestat_resultinterface, which is too low-level and local filesystem-specific
See discussion: https://discuss.python.org/t/is-there-a-pathlib-equivalent-of-os-scandir/46626
Linked PRs
- GH-125413: Add
pathlib.Path.dir_entryattribute #125419 - GH-125413:
pathlib.Path.copy(): get common metadata keys only once #125990 - GH-125413: Add
pathlib.Path.scandir()method #126060 - GH-125413: pathlib ABCs: use
scandir()to speed upglob()#126261 - GH-125413: pathlib ABCs: use
scandir()to speed upwalk()#126262 - GH-125413: pathlib: use
scandir()to speed upcopy()#126263 - GH-125413: Revert addition of
pathlib.Path.scandir()method #127377 - GH-125413: Add
pathlib.Path.infoattribute #127730 - GH-125413: Move
pathlib.Path.copy()implementation alongsidePath.info#129856 - GH-125413: Add private metadata methods to
pathlib.Path.info#129897 - GH-125413: Add private
pathlib.Pathmethod to write metadata #130238 - GH-125413: pathlib ABCs: use caching
path.info.exists()when globbing #130422 - GH-125413: Fix stale metadata from
pathlib.Path.copy()andmove()#130424
ZeroIntensity, blhsing, nineteendo and DK96-OS
Metadata
Metadata
Assignees
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-pathlibtype-featureA feature request or enhancementA feature request or enhancement