8000 GH-132566: Progressively delete files in `pathlib.Path.move()` by barneygale · Pull Request #133852 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-132566: Progressively delete files in pathlib.Path.move() #133852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use deque to consume generator
  • Loading branch information
barneygale committed May 10, 2025
commit 7dab8c968695e0a06b7bb86d5f525a8ed3a78c7a
4 changes: 2 additions & 2 deletions Lib/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os
import posixpath
import sys
from collections import deque
from errno import *
from glob import _StringGlobber, _no_recurse_symlinks
from itertools import chain
Expand Down Expand Up @@ -1092,8 +1093,7 @@ def copy(self, target, **kwargs):
if not hasattr(target, 'with_segments'):
target = self.with_segments(target)
ensure_distinct_paths(self, target)
for _dst, _src in target._iter_copy_from(self, **kwargs):
pass
deque(target._iter_copy_from(self, **kwargs), maxlen=0)
return target.joinpath() # Empty join to ensure fresh metadata.

def copy_into(self, target_dir, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions Lib/pathlib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


from abc import ABC, abstractmethod
from collections import deque
from glob import _PathGlobber
from io import text_encoding
from pathlib._os import magic_open, ensure_distinct_paths, ensure_different_files, copyfileobj
Expand Down Expand Up @@ -337,8 +338,7 @@ def copy(self, target, **kwargs):
Recursively copy this file or directory tree to the given destination.
"""
ensure_distinct_paths(self, target)
for _dst, _src in target._iter_copy_from(self, **kwargs):
pass
deque(target._iter_copy_from(self, **kwargs), maxlen=0)
return target.joinpath() # Empty join to ensure fresh metadata.

def copy_into(self, target_dir, **kwargs):
Expand Down
Loading
0