| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The following `pathlib.Path` methods now directly call functions in `os.path`: - `samefile()` - `exists()` - `is_dir()` - `is_file()` - `is_symlink()` In conjunction with python#101324, this improves performance of these methods by using making fewer system calls than `stat()` The original generic implementations of these methods are preserved in a new, internal `_PathWithStat` class. In future this may form the basis of a public `AbstractPath` class. The generic implementation of `is_mount()`, which was removed in 29650fea, is also restored to this class.
|
#101324 has landed. The general approach here makes sense. I imagine what we'll want to do is:
Alternatively, we could make the C functions always raise the exceptions that pathlib raises, and the Python wrappers in os.path would catch those exceptions and return False. I think microbenchmarking is the only way to know if any of that matters. I think we will lose a little bit of the gains of #101324 either way, but that's ok as long as it's not significant, I guess. |
Sorry, something went wrong.
We added a similar strict keyword-only argument to os.path.realpath() recently - couldn't we do that here too? |
Sorry, something went wrong.
|
I opened this PR mainly to demonstrate how to preserve pathlib's stat() helpers, but I don't have the time to bring it forward. Closing so that someone else might have a go. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The following pathlib.Path methods now directly call functions in os.path:
In conjunction with #101324, this improves performance of these methods by using making fewer system calls than stat()
The original generic implementations of these methods are preserved in a new, internal _PathWithStat class. In future this may form the basis of a public AbstractPath class. The generic implementation of is_mount(), which was removed in 29650fea, is also restored to this class.