Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-104996: Defer joining of pathlib.PurePath() arguments. #104999

Merged

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented May 26, 2023

Joining of arguments is moved to _load_parts, which is called when a normalized path is needed.

$ ./python -m timeit -s 'from pathlib import PurePath' 'PurePath("a", "b", "c")'
100000 loops, best of 5: 2.13 usec per loop  # before
200000 loops, best of 5: 1.14 usec per loop  # after
# --> 1.87x speedup.

Joining of arguments is moved to `_load_parts`, which is called when a
normalized path is needed.
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really nice (I love the approach) — just one question:

Lib/pathlib.py Show resolved Hide resolved
Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Lib/pathlib.py Show resolved Hide resolved
@miss-islington
Copy link
Contributor

Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @barneygale, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ffeaec7e60c88d585deacb10264ba7a96e5e52df 3.12

barneygale added a commit to barneygale/cpython that referenced this pull request Jun 7, 2023
…thonGH-104999)

Joining of arguments is moved to `_load_parts`, which is called when a
normalized path is needed.

(cherry picked from commit ffeaec7)
barneygale added a commit to barneygale/cpython that referenced this pull request Jun 7, 2023
…ts. (pythonGH-104999)

Joining of arguments is moved to `_load_parts`, which is called when a
normalized path is needed..
(cherry picked from commit ffeaec7)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
@bedevere-bot
Copy link

GH-105483 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 bug and security fixes label Jun 7, 2023
barneygale added a commit that referenced this pull request Jun 7, 2023
…H-104999) (GH-105483)

Joining of arguments is moved to `_load_parts`, which is called when a
normalized path is needed.

(cherry picked from commit ffeaec7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants