gh-118761: Speedup pathlib import by deferring shutil (#123520)

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Daniel Hollas 2024-09-01 15:44:48 +01:00 committed by GitHub
parent 42a818912b
commit 2304774465
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -3,7 +3,6 @@ import ntpath
import operator
import os
import posixpath
import shutil
import sys
from glob import _StringGlobber
from itertools import chain
@ -824,7 +823,10 @@ class Path(PathBase, PurePath):
"""
os.rmdir(self)
_rmtree = shutil.rmtree
def _rmtree(self):
# Lazy import to improve module import time
import shutil
shutil.rmtree(self)
def rename(self, target):
"""