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.DirEntry after calling Path.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 the stat_result interface, 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
Reactions are currently unavailable
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:
See discussion: https://discuss.python.org/t/is-there-a-pathlib-equivalent-of-os-scandir/46626
Linked PRs