Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
pathlib.Path.copy()
method.pathlib.Path.copy()
Marking this PR as a draft, because I think we'll need to introduce |
There was a problem hiding this 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!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Eryk Sun <eryksun@gmail.com>
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. |
7c38097
intopython:mainUh oh!
There was an error while loading.Please reload this page.
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>
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>
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>
Uh oh!
There was an error while loading.Please reload this page.
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:fcntl.FICLONE
where available (seeshutil: add reflink=False to file copy functions to control clone/CoW copies (use copy_file_range) #81338)os.copy_file_range
where available (seeUse copy_file_range() in shutil.copyfile() (server-side copy) #81340)_winapi.CopyFile2
where available, even though this copies more metadata than the other implementations. This makesWindowsPath.copy()
more similar toshutil.copy2()
.The method is deliberatelyless specified than the
shutil
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/