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
pathlib.Path should have a copy() method #68417
Comments
Path objects already have rename() and replace() methods; it would be useful for them also to have a copy() method to simplify that operation. I'll look into putting a patch together this evening. |
Path objects are immutable, so the copy method is not needed. |
I presume the copy method is intended as a file copy, not for copying the object. But calling the method copy() is likely to be confusing, precisely as happened here :-) |
If copy() has a mandatory argument, it can't really be mixed up with an object-cloning method. |
File renaming is simple and usually atomic operation. File copying is complex operation. What memory buffer should be used for copying? What to do with growing files or reading with errors? Should file space be preallocated before copyiong to decrease fragmentation? How handle sparse files? Can be optimized copyiong on file systems with compression? What to do with NT streams? What to do with extended attributes? What to do with directories, links and other special files? I think that pathlib is not good place for this function (as well as for handling ZIP files or playing multimedia). |
Serhiy makes a series of good points, which I hadn't really considered before filing this report. It was mostly laziness on my part while dashing off a quick script - I knew I wouldn't have to deal with the edge cases so subconsciously dismissed them, especially as the code I wrote to copy was only a couple of lines. So I'm happy for this bug to be closed with no change needed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: