Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-73991: Addpathlib.Path.copy()#119058

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
barneygale merged 19 commits intopython:mainfrombarneygale:gh-73991-copy
Jun 14, 2024
Merged

Conversation

barneygale
Copy link
Contributor

@barneygalebarneygale commentedMay 14, 2024
edited
Loading

Add aPath.copy() method that copies the content of one file to another.

This method is similar toshutil.copyfile() but differs in the following ways:

The method is deliberatelyless specified than theshutil functions to allow OS-specific optimizations that might copy more or less metadata.

Incorporates code by@illia-v and@giampaolo from#81338 and#93152 respectively.


📚 Documentation preview 📚:https://cpython-previews--119058.org.readthedocs.build/

nineteendo reacted with thumbs up emoji
Add a `Path.copy()` method that copies a file to a target file or directoryusing `shutil.copy2()`.In the private pathlib ABCs, we add a version that supports copying fromone instance of `PathBase` to another. We don't copy metadata, becausedoing so probably requires new APIs that haven't been designed yet.
@barneygalebarneygale changed the titleGH-73991: Addpathlib.Path.copy() method.GH-73991: Addpathlib.Path.copy()May 15, 2024
@barneygale
Copy link
ContributorAuthor

Marking this PR as a draft, because I think we'll need to introduceos.copy() first.

@barneygalebarneygale marked this pull request as draftMay 27, 2024 14:40
@barneygalebarneygale marked this pull request as ready for reviewJune 3, 2024 06:42
@barneygalebarneygale requested a review fromzoobaJune 3, 2024 20:56
Copy link
Member

@zoobazooba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just some thoughts, nothing I'd necessarily block the PR on. I like the way it looks overall!

@zooba
Copy link
Member

Looks fine to me, but I only quickly reskimmed it. I'll be away for the next few days, so don't wait for me if you guys think it's ready.

barneygale reacted with heart emoji

@barneygalebarneygale merged commit7c38097 intopython:mainJun 14, 2024
33 checks passed
mrahtz pushed a commit to mrahtz/cpython that referenced this pull requestJun 30, 2024
Add a `Path.copy()` method that copies the content of one file to another.This method is similar to `shutil.copyfile()` but differs in the following ways:- Uses `fcntl.FICLONE` where available (seepythonGH-81338)- Uses `os.copy_file_range` where available (seepythonGH-81340)- Uses `_winapi.CopyFile2` where available, even though this copies more metadata than the other implementations. This makes `WindowsPath.copy()` more similar to `shutil.copy2()`.The method is presently _less_ specified than the `shutil` functions to allow OS-specific optimizations that might copy more or less metadata.Incorporates code frompythonGH-81338 andpythonGH-93152.Co-authored-by: Eryk Sun <eryksun@gmail.com>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull requestJul 11, 2024
Add a `Path.copy()` method that copies the content of one file to another.This method is similar to `shutil.copyfile()` but differs in the following ways:- Uses `fcntl.FICLONE` where available (seepythonGH-81338)- Uses `os.copy_file_range` where available (seepythonGH-81340)- Uses `_winapi.CopyFile2` where available, even though this copies more metadata than the other implementations. This makes `WindowsPath.copy()` more similar to `shutil.copy2()`.The method is presently _less_ specified than the `shutil` functions to allow OS-specific optimizations that might copy more or less metadata.Incorporates code frompythonGH-81338 andpythonGH-93152.Co-authored-by: Eryk Sun <eryksun@gmail.com>
estyxx pushed a commit to estyxx/cpython that referenced this pull requestJul 17, 2024
Add a `Path.copy()` method that copies the content of one file to another.This method is similar to `shutil.copyfile()` but differs in the following ways:- Uses `fcntl.FICLONE` where available (seepythonGH-81338)- Uses `os.copy_file_range` where available (seepythonGH-81340)- Uses `_winapi.CopyFile2` where available, even though this copies more metadata than the other implementations. This makes `WindowsPath.copy()` more similar to `shutil.copy2()`.The method is presently _less_ specified than the `shutil` functions to allow OS-specific optimizations that might copy more or less metadata.Incorporates code frompythonGH-81338 andpythonGH-93152.Co-authored-by: Eryk Sun <eryksun@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@zoobazoobaAwaiting requested review from zooba

@eryksuneryksunAwaiting requested review from eryksun

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@barneygale@zooba@eryksun

[8]ページ先頭

©2009-2025 Movatter.jp