Commit d88677a
authored
In the following methods, skip casting of the argument to a path object if
the 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. This
improves performance a bit, because `isinstance()` checks on ABCs are
expensive.
1 parent 286c517 commit d88677a
File tree
3 files changed
+24
-18
lines changed- Lib/pathlib
- Misc/NEWS.d/next/Library
3 files changed
+24
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| |||
366 | 366 | | |
367 | 367 | | |
368 | 368 | | |
369 | | - | |
| 369 | + | |
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | | - | |
| 567 | + | |
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| |||
1064 | 1064 | | |
1065 | 1065 | | |
1066 | 1066 | | |
1067 | | - | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
1068 | 1070 | | |
1069 | 1071 | | |
1070 | 1072 | | |
| |||
1077 | 1079 | | |
1078 | 1080 | | |
1079 | 1081 | | |
1080 | | - | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
1081 | 1085 | | |
1082 | 1086 | | |
1083 | 1087 | | |
| |||
1086 | 1090 | | |
1087 | 1091 | | |
1088 | 1092 | | |
1089 | | - | |
| 1093 | + | |
1090 | 1094 | | |
1091 | 1095 | | |
1092 | 1096 | | |
| |||
1104 | 1108 | | |
1105 | 1109 | | |
1106 | 1110 | | |
1107 | | - | |
| 1111 | + | |
1108 | 1112 | | |
1109 | 1113 | | |
1110 | 1114 | | |
| |||
1118 | 1122 | | |
1119 | 1123 | | |
1120 | 1124 | | |
1121 | | - | |
| 1125 | + | |
1122 | 1126 | | |
1123 | 1127 | | |
1124 | 1128 | | |
1125 | | - | |
1126 | | - | |
1127 | 1129 | | |
1128 | 1130 | | |
1129 | | - | |
1130 | | - | |
| 1131 | + | |
1131 | 1132 | | |
1132 | 1133 | | |
1133 | 1134 | | |
| |||
1143 | 1144 | | |
1144 | 1145 | | |
1145 | 1146 | | |
1146 | | - | |
| 1147 | + | |
1147 | 1148 | | |
1148 | 1149 | | |
1149 | 1150 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments