GH-101362: Omit path anchor from pathlib.PurePath()._parts (GH-102476)

Improve performance of path construction by skipping the addition of the path anchor (`drive + root`) to the internal `_parts` list. Rename this attribute to `_tail` for clarity.
This commit is contained in:
Barney Gale 2023-04-09 18:40:03 +01:00 committed by GitHub
parent 0a675f4bb5
commit 2c673d5e93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 108 additions and 67 deletions

View file

@ -346,8 +346,6 @@ class _BasePurePathTest(object):
p = P('a/b')
parts = p.parts
self.assertEqual(parts, ('a', 'b'))
# The object gets reused.
self.assertIs(parts, p.parts)
# When the path is absolute, the anchor is a separate part.
p = P('/a/b')
parts = p.parts