diff options
author | Barney Gale <barney.gale@gmail.com> | 2023-03-05 23:50:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 23:50:21 (GMT) |
commit | 6716254e71eeb4666fd6d1a13857832caad7b19f (patch) | |
tree | f069df2fd49f583efad636c7fc34f483b6d2a5e9 /Python/errors.c | |
parent | 3e60e0213e9d884a2f4cef4df96956c5d4adde0a (diff) | |
download | cpython-6716254e71eeb4666fd6d1a13857832caad7b19f.zip cpython-6716254e71eeb4666fd6d1a13857832caad7b19f.tar.gz cpython-6716254e71eeb4666fd6d1a13857832caad7b19f.tar.bz2 |
GH-101362: Optimise PurePath(PurePath(...)) (GH-101667)
The previous `_parse_args()` method pulled the `_parts` out of any supplied `PurePath` objects; these were subsequently joined in `_from_parts()` using `os.path.join()`. This is actually a slower form of joining than calling `fspath()` on the path object, because it doesn't take advantage of the fact that the contents of `_parts` is normalized!
This reduces the time taken to run `PurePath("foo", "bar")` by ~20%, and the time taken to run `PurePath(p, "cheese")`, where `p = PurePath("/foo", "bar", "baz")`, by ~40%.
Automerge-Triggered-By: GH:AlexWaygood
Diffstat (limited to 'Python/errors.c')
0 files changed, 0 insertions, 0 deletions