GH-101362: Call join() only when >1 argument supplied to pathlib.PurePath
This reduces the time taken to run `PurePath("foo")` by ~15%
def _parse_parts(cls, parts):
if not parts:
return '', '', []
+ elif len(parts) == 1:
+ path = os.fspath(parts[0])
+ else:
+ path = cls._flavour.join(*parts)
sep = cls._flavour.sep
altsep = cls._flavour.altsep
- path = cls._flavour.join(*parts)
if altsep:
path = path.replace(altsep, sep)
drv, root, rel = cls._flavour.splitroot(path)
--- /dev/null
+Speed up :class:`pathlib.PurePath` construction by calling
+:func:`os.path.join` only when two or more arguments are given.