Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-128520: More consistent type-checking behaviour in pathlib#130199

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
barneygale merged 6 commits intopython:mainfrombarneygale:gh-128520-isinstance
Feb 21, 2025

Conversation

barneygale
Copy link
Contributor

@barneygalebarneygale commentedFeb 16, 2025
edited
Loading

In the following methods, skip casting of the argument to a path object if the argument has awith_segments attribute.

  • InPurePath:relative_to(),is_relative_to(),match(), andfull_match().
  • InPath:rename(),replace(),copy(),copy_into(),move(), andmove_into().

Previously the check varied a bit from method to method. ThePurePath methods checkedisinstance(arg, PurePath); therename() andreplace() methods always cast, and the remainingPath methods checked for a privatearg._copy_writer attribute.

We apply identical changes to relevant methods of the private ABCs. This improves performance a bit, becauseisinstance() checks on ABCs are expensive.

In the following methods, skip casting of the argument to a path object ifthe argument has a `with_segments` attribute. In `PurePath`:`relative_to()`, `is_relative_to()`, `match()`, and `full_match()`. In`Path`: `rename()`, `replace()`, `copy()`, `copy_into()`, `move()`, and`move_into()`.Previously the check varied a bit from method to method. The `PurePath`methods used `isinstance(arg, PurePath)`; the `rename()` and `replace()`methods always cast, and the remaining `Path` methods checked for a private`_copy_writer` attribute.We apply identical changes to relevant methods of the private ABCs. Thisimproves performance a bit, because `isinstance()` checks on ABCs areexpensive.
@barneygalebarneygale merged commitd88677a intopython:mainFeb 21, 2025
39 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@barneygale

[8]ページ先頭

©2009-2025 Movatter.jp