FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-137855: Improve import time of `pathlib` by hugovk · Pull Request #146327 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 2 additions & 3 deletions Lib/pathlib/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
import posixpath
import sys
from errno import *
from glob import _StringGlobber, _no_recurse_symlinks
from itertools import chain
from stat import (
S_IMODE, S_ISDIR, S_ISREG, S_ISLNK, S_ISSOCK, S_ISBLK, S_ISCHR, S_ISFIFO,
)
from _collections_abc import Sequence
lazy import shutil
lazy from glob import _StringGlobber, _no_recurse_symlinks

try:
import pwd
Expand Down Expand Up @@ -1255,8 +1256,6 @@ def _delete(self):
if self.is_symlink() or self.is_junction():
self.unlink()
elif self.is_dir():
# Lazy import to improve module import time
import shutil
shutil.rmtree(self)
else:
self.unlink()
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_pathlib/test_pathlib.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_is_notimplemented(self):
class LazyImportTest(unittest.TestCase):
@cpython_only
def test_lazy_import(self):
import_helper.ensure_lazy_imports("pathlib", {"shutil"})
import_helper.ensure_lazy_imports("pathlib", {"glob", "shutil"})


#
Expand Down
Loading

Back | FazBrowse Home | New Git URL