Skip to content

Speed up pathlib.PurePath.[is_]relative_to() #111429

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

Closed
barneygale opened this issue Oct 28, 2023 · 1 comment
Closed

Speed up pathlib.PurePath.[is_]relative_to() #111429

barneygale opened this issue Oct 28, 2023 · 1 comment
Labels
performance Performance or resource usage topic-pathlib

Comments

@barneygale
Copy link
Contributor

barneygale commented Oct 28, 2023

Both methods call self.with_segments() unconditionally. This can be skipped if the other argument is already an instance of PurePath, and no further (deprecated) positional arguments are given.

Also, relative_to() can inline the core of the is_relative_to() check to avoid the type/deprecated args checks.

Linked PRs

@barneygale
Copy link
Contributor Author

barneygale commented Nov 12, 2023

Resolved in 3.13 / 6e93540 / #111431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage topic-pathlib
Projects
None yet
Development

No branches or pull requests

1 participant